应用(9.2)和第三方库(8.4)中不同Google Play服务版本之间的冲突

时间:2016-06-30 15:11:59

标签: android google-play-services

我正在使用Android Studio的Android项目中工作。

此项目是一个使用某些第三方库的应用程序。其中一个使用Google Play Services 8.4.0,但我的应用使用Google Play Services 9.2.0,我需要将此版本用于该应用的某些特定功能。

当我使用此依赖项编译和执行应用程序时

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

当我执行应用程序并执行第三部分库的代码时,我得到此错误(总结):

致命的例外:主要 处理:com.example.app,PID:507                                                                               java.lang.NoClassDefFoundError:解析失败:Lcom / google / android / gms / maps / model / LatLng;                                                                                引起:java.lang.ClassNotFoundException:未在路径上找到“com.google.android.gms.maps.model.LatLng”类:DexPathList

如果我将Google Play服务版本降级到8.4.0就可以了,问题是我必须从应用中删除我的应用Google Play Services 9.2.0功能。

有没有办法强制第三方图书馆使用自己的Google Play服务库版本并允许我的应用使用上一个Google Play服务版本?

2 个答案:

答案 0 :(得分:1)

更新到9.x.x版时,Google Play服务存在很多问题/问题。截至目前,我认为它仍然有一些bug issue

现在,针对您收到的错误java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.maps.model.LatLng" on path: DexPathList。这是您用于谷歌地图API的jar文件的问题。检查罐子或下载适当的罐子。您可以反编译jar并查看有关类的信息。类文件不存在,因为它在日志中提到。

你也可以试试其他解决方案就是这个问题:

答案 1 :(得分:0)

在项目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
}

并在你的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'