【问题标题】:Conflicts between different Google Play Services versions in an app (9.2) and a third party library (8.4)应用 (9.2) 和第三方库 (8.4) 中不同 Google Play 服务版本之间的冲突
【发布时间】:2016-06-30 15:11:59
【问题描述】:

我正在使用 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 Services 版本降级到 8.4.0,它可以正常工作,但问题是我必须从应用中删除我的应用 Google Play Services 9.2.0 功能。

有没有办法强制第三方库使用其自己的 Google Play 服务库版本并允许我的应用使用最新的 Google Play 服务版本?

【问题讨论】:

  • 嗨,我正在使用 myflashlab 上的 play-services-ane 版本 9.6.8 和我的 AIR android 项目 (AIR SDK 24.0)。我收到相同的运行时错误:LatLng 类上的 CalssNotFoundException。你解决了你的问题吗?如果是,请帮我解决这个问题。

标签: android google-play-services


【解决方案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 或下载正确的 jar。您可以反编译 jar 并查看有关类。日志中提到的类文件不存在。

您也可以尝试其他解决方案是这样的问题:

【讨论】:

  • 等等,我将 play-services-base jar 文件中的 gms.common 作为单独的文件包含在内(用于 Adob​​e AIR 构建)。它确实包含 GooglePlayServicesUitl.class。但是,在运行时我的应用程序崩溃:ClassNotFoundException Didn't find class GooglePlayServicesUtil on path DexPathList
【解决方案2】:

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

并在您的应用 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'

【讨论】:

  • 为什么会这样?似乎正在导入两个不同的版本。
  • 这里有两个不同的版本。我在我的应用程序中使用它并且工作正常。
  • 我相信它确实有效。我只是想知道为什么,因为对我来说,看起来play services 3.0.0play services 9.2.0 都被导入了。我误解了我的想法。
  • 其实我认为你没有仔细阅读我的回答。我分别发布了 app build.gradle 和 project build.gradle,这是两个不同的文件,其中导入了两个不同的版本。
猜你喜欢
  • 2016-03-22
  • 2021-12-08
  • 1970-01-01
  • 2019-02-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多