0

的Android 2.2.2工作室面临运行时错误不止一个库包名“com.google.android.gms”

说默认依赖= compile 'com.google.android.gms:play-services:9.8.0'

我面临的运行时此错误:

Error:java.lang.RuntimeException: Error: more than one library with package name 'com.google.android.gms'

当我试图用我需要在我的项目中减少执行时间的特定依赖项替换默认播放服务依赖项。

这里是我的应用程序级别gradle这个文件:

apply plugin: 'com.android.application' 

android { 

    compileSdkVersion 25 
    buildToolsVersion '25.0.0' 
    useLibrary 'org.apache.http.legacy' 

    lintOptions { 
     checkReleaseBuilds false 
    } 

    defaultConfig { 
     applicationId "com.blucursor.gpstrack" 
     minSdkVersion 19 
     targetSdkVersion 23 
     multiDexEnabled true 
     versionCode 16 
     versionName "2.0" 
     resConfigs "en", "fr" 

    } 

    signingConfigs { 
     release { 
      storeFile file("C:\\******\\********.jks") 
      storePassword "********" 
      keyAlias "*******" 
      keyPassword "******" 
     } 
    } 

    buildTypes { 
     release { 
      minifyEnabled true 
      shrinkResources true 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt' 
      signingConfig signingConfigs.release 
      zipAlignEnabled true 

     } 
    } 
} 

dependencies { 

    compile files('libs/android-query-full.0.26.8.jar') 
    compile files('libs/GraphView-4.0.1.jar') 
    //compile 'com.google.android.gms:play-services:9.8.0' 
    compile 'com.google.android.gms:play-services-maps:9.8.0' 
    compile 'com.google.android.gms:play-services-gcm:9.8.0' 
    compile 'com.android.support:appcompat-v7:25.0.0' 
    compile 'com.android.support:support-v4:25.0.0' 
    compile 'com.android.support:design:25.0.0' 
    compile 'com.android.support:cardview-v7:25.0.0' 
    compile 'com.android.support:recyclerview-v7:25.0.0' 
    compile 'com.google.maps.android:android-maps-utils:0.3' 
    compile 'com.google.firebase:firebase-ads:9.4.0' 
    compile 'com.moxun:tagcloudlib:1.1.3' 
    compile 'io.realm:realm-android:0.84.1' 
} 
apply plugin: 'com.google.gms.google-services' 

这里的项目级别gradle这个文件:

// 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.2.2' 
     classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3' 
     classpath 'com.google.gms:google-services:3.0.0' 

    } 
} 

allprojects { 
    repositories { 
     jcenter() 
    } 
} 

task clean(type: Delete) { 
    delete rootProject.buildDir 
} 

当我建立与默认这工作正常,一个即: compile 'com.google.android.gms:play-services:9.4.0'

我试过的: 我跟踪的来源。

我见过很多解决方案,说你要么使用播放服务依赖或特定的依赖。 我试图做同样的事情,但它似乎并不适合我。 有帮助吗?

编辑:即使我删除所有的Play商店依赖关系,仍然存在相同的错误。

我也试过更新app.iml文件,并删除了其他不需要该项目的playstore依赖项,但这仍然不起作用。

+1

您是否尝试过让Firebase使用与播放服务相同的版本? –

+0

是的,我也试过,但没有成功。 – VishAl

+1

那么,正如你链接指出的那些问题,你应该能够使用命令行 –

回答

-2

from project level gradle file删除此行classpath'com.google.gms:google-services:3.0.0'。

因为您已经在您的应用程序级别的gradle文件中使用。

+0

我认为有必要使用这一行,因为这对于在应用级gradle中使用“插件:'com.google.gms.google-services'”非常重要。 – VishAl

+0

您是否尝试过从应用程序gradle文件中删除该行和插件行。 – Deepak

+0

因为您已经在使用 – Deepak

0

我得到了同样的问题,但我这样做

dependencies { 
     classpath 'com.android.tools.build:gradle:2.2.3' 
     classpath 'com.google.gms:google-services:3.0.0' //use this version as the newest version 
    } 

和我这样做太

dependencies { 
. 
. 
. 
    // compile project(':google-play-services') comment because this version isn't same with my firebase version, try to get the last google-play-service jar/compile the last version 
    compile 'com.google.android.gms:play-services:10.2.0' 
    compile ('com.google.firebase:firebase-messaging:10.2.0'){ 
      exclude group: 'com.google.android.gms', module: 'com.google.android.gms' 
     } 
    } 
    apply plugin: 'com.google.gms.google-services' // i do it on every project i have 

然后,同步你的项目,并清理项目 可能这个帮助你,我想谷歌播放服务的版本应该与Firebase版本相同

更新

尝试使您的gms版本与您的firebase版本相同(如果您使用9.8。0 gms,在firebase中使用9.8.0)