4

I am working in an Android project using Android Studio.

This project is an app that uses some third party libraries. One of them uses Google Play Services 8.4.0, but my app uses Google Play Services 9.2.0, and I need to use this version to some specific features of the app.

When I compile and execute the application with this dependencies

compile 'com.google.android.gms:play-services-gcm:9.2.0' compile 'com.google.android.gms:play-services-location:9.2.0'

I get this error (in summary) when I execute the app and the code of the third part library is executed:

FATAL EXCEPTION: main Process: com.example.app, PID: 507 java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/maps/model/LatLng; Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.maps.model.LatLng" on path: DexPathList

If I downgrade the Google Play Services version to 8.4.0 it works ok, the problem is that I have to remove my app Google Play Services 9.2.0 features from the app.

Is there a way to force the third party library to use its own Google Play Services Library version and allow my app to use last Google Play Services version?

gabicuesta
  • 329
  • 5
  • 17
  • Hi, I am using play-services-ane version 9.6.8 found on myflashlab with my AIR android project (AIR SDK 24.0). I am getting the same runtime error: CalssNotFoundException on LatLng class. Did you solve your issue? If yes, please help me solve this issue. – Mazhar Nov 18 '16 at 15:23

2 Answers2

1

There is alot of problem/issue about the Google Play Service when updating to version 9.x.x. As of now, I think it is still have some bug issue.

Now, for the error that you receive java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.maps.model.LatLng" on path: DexPathList. It is a problem with the jar file that you are using for google maps API. Check the jar or else download proper jar. You can decompile the jar and see regarding classes. Class file is not present as it is mentioned in the log.

You can also try the other solution is this SO questions:

Community
  • 1
  • 1
KENdi
  • 7,576
  • 2
  • 16
  • 31
  • Wait, I am including gms.common from play-services-base jar file as a separate file (for Adobe AIR build). It does contain **GooglePlayServicesUitl.class**. However, at runtime my app crashes with: `ClassNotFoundException Didn't find class GooglePlayServicesUtil on path DexPathList` – IgorGanapolsky Aug 22 '16 at 15:30
0

use this in your project build.gradle

 dependencies {
    classpath 'com.android.tools.build:gradle:2.1.2'
    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
}

and use this in your app build.gradle

repositories {
    mavenCentral()
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'

    compile 'com.android.support:appcompat-v7:24.0.0'
    compile 'com.android.support:design:24.0.0'
    compile 'com.google.android.gms:play-services-auth:9.2.0'
    compile 'com.android.support:cardview-v7:24.0.0'
    compile 'com.android.support:support-v4:24.0.0'
    compile 'com.mcxiaoke.volley:library-aar:1.0.0'

}
apply plugin: 'com.google.gms.google-services'
Umar Ata
  • 4,170
  • 3
  • 23
  • 35
  • Why does this work? It looks like two different versions are being imported. – Gi0rgi0s Jul 29 '16 at 15:56
  • where is two different versions. I am using this in my app and its working fine. – Umar Ata Jul 29 '16 at 17:46
  • I believe it does work. I'm just wondering why, because to me, it looks like `play services 3.0.0` and `play services 9.2.0` are both being imported. I'm misunderstanding something I think. – Gi0rgi0s Jul 29 '16 at 18:34
  • 2
    actually I think you are not read my answer carefully. I posted app build.gradle and project build.gradle separately and these are two different files in which two different versions are imported. – Umar Ata Jul 29 '16 at 18:40