Pourquoi j'ai cette erreur lorsque sur google map "Échec du chargement de DynamiteLoader: java.lang.ClassNotFoundException: Ne pas à trouver de la classe?
Je suis en train de dessiner un chemin entre deux de latitude,de longitude. Voici mon MapsActivity.java.
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_maps);
//Obtain the SupportMapFragment and get notified when the map is ready to be used.
SupportMapFragment mapFragment = (SupportMapFragment)
getSupportFragmentManager()
.findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
find = (Button) findViewById(R.id.btnFindPath);
or = (EditText) findViewById(R.id.etOrigin);
dest = (EditText) findViewById(R.id.etDestination);
find.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
sendRequest();
}
});
}
public void sendRequest(){
String origin = or.getText().toString();
String destination = dest.getText().toString();
if(origin.isEmpty()){
Toast.makeText(this,"Please Enter the Origin" , Toast.LENGTH_SHORT).show();
}
if(destination.isEmpty()){
Toast.makeText(this,"Please Enter the Destination" , Toast.LENGTH_SHORT).show();
}
DirectionFinder directionFinder = new DirectionFinder(origin, destination);
}
@Override
public void onMapReady(GoogleMap googleMap) {
mMap = googleMap;
/*double array [] = {44.968046 ,-94.420307 ,44.33328,-89.132008, 33.755787,-116.359998,33.844843,-116.54911 ,44.92057 ,-93.44786};
//Add a marker in Sydney and move the camera
for ( int i = 0 ; i< array.length ; i = i+2){
LatLng place = new LatLng( array[i], array[i+1]);
mMap.addMarker(new MarkerOptions().position(place).title("Marker in"+ i));
mMap.moveCamera(CameraUpdateFactory.newLatLng(place));
}
}
}
Mon DirectionFinder.java est:
public DirectionFinder( String or , String dest) {
if(or.equals("PRAN RFL")){
double lat1 = 23.781388 ;
double lon1 = 90.425500 ;
LatLng origin = new LatLng( lat1, lon1);
}
if(dest.equals("Gulshan")){
double lat2 = 23.780270 ;
double lon2 = 23.780270 ;
LatLng destination = new LatLng( lat2, lon2);
}
//this.listener = listener;
//this.origin = origin;
//this.destination = destination;
}
public void execute() throws UnsupportedEncodingException {
listener.onDirectionFinderStart();
new DownloadRawData().execute(createUrl());
}
private String createUrl() throws UnsupportedEncodingException {
String urlOrigin = URLEncoder.encode(origin, "utf-8");
String urlDestination = URLEncoder.encode(destination, "utf-8");
return DIRECTION_URL_API + "origin=" + urlOrigin + "&destination=" + urlDestination + "&key=" + GOOGLE_API_KEY;
}
private class DownloadRawData extends AsyncTask<String, Void, String> {
@Override
protected String doInBackground(String... params) {
String link = params[0];
try {
URL url = new URL(link);
InputStream is = url.openConnection().getInputStream();
StringBuffer buffer = new StringBuffer();
BufferedReader reader = new BufferedReader(new InputStreamReader(is));
String line;
while ((line = reader.readLine()) != null) {
buffer.append(line + "\n");
}
return buffer.toString();
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
@Override
protected void onPostExecute(String res) {
try {
parseJSon(res);
} catch (JSONException e) {
e.printStackTrace();
}
}
}
private void parseJSon(String data) throws JSONException {
if (data == null)
return;
List<Route> routes = new ArrayList<Route>();
JSONObject jsonData = new JSONObject(data);
JSONArray jsonRoutes = jsonData.getJSONArray("routes");
for (int i = 0; i < jsonRoutes.length(); i++) {
JSONObject jsonRoute = jsonRoutes.getJSONObject(i);
Route route = new Route();
JSONObject overview_polylineJson = jsonRoute.getJSONObject("overview_polyline");
JSONArray jsonLegs = jsonRoute.getJSONArray("legs");
JSONObject jsonLeg = jsonLegs.getJSONObject(0);
JSONObject jsonDistance = jsonLeg.getJSONObject("distance");
JSONObject jsonDuration = jsonLeg.getJSONObject("duration");
JSONObject jsonEndLocation = jsonLeg.getJSONObject("end_location");
JSONObject jsonStartLocation = jsonLeg.getJSONObject("start_location");
route.distance = new Distance(jsonDistance.getString("text"), jsonDistance.getInt("value"));
route.duration = new Duration(jsonDuration.getString("text"), jsonDuration.getInt("value"));
route.endAddress = jsonLeg.getString("end_address");
route.startAddress = jsonLeg.getString("start_address");
route.startLocation = new LatLng(jsonStartLocation.getDouble("lat"), jsonStartLocation.getDouble("lng"));
route.endLocation = new LatLng(jsonEndLocation.getDouble("lat"), jsonEndLocation.getDouble("lng"));
route.points = decodePolyLine(overview_polylineJson.getString("points"));
routes.add(route);
}
listener.onDirectionFinderSuccess(routes);
}
private List<LatLng> decodePolyLine(final String poly) {
int len = poly.length();
int index = 0;
List<LatLng> decoded = new ArrayList<LatLng>();
int lat = 0;
int lng = 0;
while (index < len) {
int b;
int shift = 0;
int result = 0;
do {
b = poly.charAt(index++) - 63;
result |= (b & 0x1f) << shift;
shift += 5;
} while (b >= 0x20);
int dlat = ((result & 1) != 0 ? ~(result >> 1) : (result >> 1));
lat += dlat;
shift = 0;
result = 0;
do {
b = poly.charAt(index++) - 63;
result |= (b & 0x1f) << shift;
shift += 5;
} while (b >= 0x20);
int dlng = ((result & 1) != 0 ? ~(result >> 1) : (result >> 1));
lng += dlng;
decoded.add(new LatLng(
lat / 100000d, lng / 100000d
));
}
return decoded;
}
}
mon activité mise en page est:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:map="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:context="com.pran.trackingapp.MapsActivity"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/etOrigin"
android:hint="Enter origin address" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Enter destination address"
android:id="@+id/etDestination" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Find path"
android:id="@+id/btnFindPath" />
<ImageView
android:layout_marginLeft="20dp"
android:layout_marginTop="5dp"
android:layout_width="40dp"
android:layout_height="40dp" />
<TextView
android:layout_marginLeft="5dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="0 km"
android:id="@+id/tvDistance" />
<ImageView
android:layout_marginLeft="20dp"
android:layout_marginTop="5dp"
android:layout_width="40dp"
android:layout_height="40dp"
android:padding="5dp" />
<TextView
android:layout_marginLeft="5dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="0 min"
android:id="@+id/tvDuration" />
</LinearLayout>
<fragment
android:id="@+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
Mais après avoir cliqué sur le bouton findpath il a généré le message d'erreur:
**
E/DynamiteModule: Échec du chargement de DynamiteLoader:
java.lang.ClassNotFoundException: Ne pas à trouver la classe
"com.google.android.gms.de la dynamite.DynamiteModule$DynamiteLoaderClassLoader"
sur le chemin: DexPathList[[fichier zip
"/data/app/com.pran.trackingapp-2/base.apk"],nativeLibraryDirectories
**
mon build.gradle (Module) est:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.0"
defaultConfig {
applicationId "com.pran.trackingapp"
minSdkVersion 16
targetSdkVersion 25
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:25.0.0'
compile 'com.google.android.gms:play-services:9.8.0'
}
mon build.gradle(Projet):
//Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.0.0'
classpath 'com.google.gms:google-services:3.0.0'
//NOTE: Do not place your application dependencies here; they belong
//in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
et le chemin d'accès ne sont pas dessinées.Que puis-je faire maintenant?
build.gradle
ici?Oui,j'ai ajouté
Je pense que vous oubliez d'ajouter appliquer plugin: com.google.gms.google-services dans votre gradle
et avez-vous ajouter classpath 'com.google.gms:google-services:3.0.0 " dans de niveau Supérieur fichier de build
OriginalL'auteur demo demo | 2016-11-20
Vous devez vous connecter pour publier un commentaire.
Faire les changements suivants dans votre application gradle fichiers.
Celui-ci est pour construire.gradle(du Projet://le nom de votre projet)
ajouter
classpath 'com.google.gms:google-services:3.0.0'
dans dependeniesEt c'est un de votre.gradle (Module:app)
Ne pas ajouter cette ligne si vous n'utilisez pas d'autres services de google s'attendre à des cartes
il suffit d'ajouter ce sur le haut ou le bas du fichier
apply plugin: 'com.google.gms.google-services'
J'espère que cela va vous aider.
collez les deux gradle fichiers merci
Après j'ai ajouté "appliquer le plugin: com.google.gms.google-services" , j'ai l'erreur : "Erreur:échec de l'Exécution de la tâche:app:processDebugGoogleServices'. > Merci de résoudre le conflit de version, soit par la mise à jour de la version de la google-services plugin (informations sur la dernière version est disponible à l'adresse bintray.com/android/android-tools/...) ou la mise à jour de la version de com.google.android.gms pour 9.0.0."
Je ne comprends pas.. vous d'abord lui dire d'ajouter l'appliquer plugin ligne et après il obtient des erreurs de lui dire d'enlever la même ligne???
Salut @ZeeshanShabbir j'ai le même problème mais j'ai toujours pas de solution pour elle. Je suppose que j'ai eu ce problème quand j'étais en ajoutant firebase pour mon projet, je peux poster et obtenir un peu d'aide?
OriginalL'auteur Zeeshan Shabbir