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

Android 应用程序(9.2)和第三方库(8.4)中不同Google Play服务版本之间的冲突,android,google-play-services,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 s

我在一个使用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:在路径:DexPathList上未找到类“com.google.android.gms.maps.model.LatLng”

如果我将Google Play Services的版本降级到8.4.0,它就可以正常工作,问题是我必须从应用程序中删除我的应用程序Google Play Services 9.2.0的功能


是否有办法强制第三方库使用其自己的Google Play Services库版本,并允许我的应用程序使用上一个Google Play Services版本?

当更新到9.x.x版本时,Google Play服务存在很多问题。到目前为止,我认为它仍然有一些

现在,对于您收到的错误,
java.lang.ClassNotFoundException:在路径:DexPathList
上未找到类“com.google.android.gms.maps.model.LatLng”。您用于GoogleMapsAPI的jar文件有问题。检查jar或者下载合适的jar。您可以反编译jar并查看关于类的信息。日志中提到的类文件不存在

您也可以尝试另一种解决方案,即以下问题:


在项目构建中使用此选项。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
}
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'
并在你的应用程序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
}
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'

为什么这样做有效?似乎正在导入两个不同的版本。其中是两个不同的版本。我正在我的应用程序中使用它,它运行良好。我相信它确实有效。我只是想知道为什么,因为在我看来,
playservices3.0.0
playservices9.2.0
都在导入。我误解了我的想法。事实上,我认为你没有仔细阅读我的答案。我分别发布了app build.gradle和project build.gradle,这是两个不同的文件,其中导入了两个不同的版本。等等,我将play services base jar文件中的gms.common作为一个单独的文件(用于Adobe AIR build)。它确实包含GooglePlayServicesUitl.class。然而,在运行时,我的应用程序崩溃了:
ClassNotFoundException在路径DexPathList上找不到类GooglePlayServicesUtil
Hi,我使用的是在我的AIR android项目(AIR SDK 24.0)的myflashlab上找到的play services电子版9.6.8。我得到了相同的运行时错误:LatLng类上的CalsNotFoundException。你的问题解决了吗?如果是,请帮我解决这个问题。