【问题标题】:Error: more than one library with package name 'com.google.android.gms.license'错误:多个库的包名称为“com.google.android.gms.license”
【发布时间】:2018-03-23 15:59:18
【问题描述】:

今天,我打开了 Android Studio,然后我得到了这个错误。昨天,没有这样的问题!

错误:任务 ':app:processDebugResources' 执行失败。

错误:多个库的包名称为“com.google.android.gms.license”

com.google.android.gms:play-services-xxx 库是

11.8.0

Onesignal 库是

'com.onesignal:OneSignal:[3.6.2, 3.99.99]'

然后我将它们更改为最新版本。

现在应用/Gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 27
    buildToolsVersion "23.0.3"

    defaultConfig {
        applicationId "xxx.xxx.xxx"
        minSdkVersion 15
        targetSdkVersion 24
        versionCode 10
        versionName 'x.x.x'
        manifestPlaceholders = [onesignal_app_id: "xxxxx-xx-xxx",
                                // Project number pulled from dashboard, local value is ignored.
                                onesignal_google_project_number: "XXX"]

    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    productFlavors {
    }
}

repositories {
    maven { url 'https://maven.google.com' }
}


dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.mcxiaoke.volley:library:1.0.18'
    compile 'com.github.chrisbanes.photoview:library:1.2.3'
    compile 'com.facebook.android:facebook-android-sdk:4.0.1'
    compile 'com.google.android.gms:play-services-ads:12.0.0'

    //compile 'com.google.android.gms:play-services-ads:11.2.2'

    compile 'com.pkmmte.view:circularimageview:1.1'
    compile 'com.melnykov:floatingactionbutton:1.3.0'
    compile 'com.squareup.okhttp:okhttp:2.5.0'
    compile 'com.github.bumptech.glide:glide:3.7.0'
    //compile 'com.android.support:appcompat-v7:26.1.0'

    compile 'com.android.support:appcompat-v7:27.1.0'
    compile 'com.android.support:cardview-v7:27.1.0'
    compile 'com.android.support:recyclerview-v7:27.1.0'
    compile 'com.android.support:design:27.1.0'
    compile 'com.balysv:material-ripple:1.0.2'
    compile "com.google.firebase:firebase-messaging:12.0.0"
    compile 'com.github.hotchemi:android-rate:1.0.1'
    compile 'com.onesignal:OneSignal:[3.7.1, 3.99.99]'
    compile 'com.google.android.gms:play-services-analytics:12.0.0'
}

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.3'

        classpath 'com.google.gms:google-services:3.1.1'

      //  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
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

但我仍然遇到上述相同的错误。我怎么解决这个问题?为什么昨天没有问题,今天又出现了这个问题?

【问题讨论】:

  • 没有人回答。知道的请回答。谢谢..
  • 您在两个地方添加了相同的依赖项,正如错误所说。在顶级 Project/Gradle 和“模块”应用程序中 ...
  • 看不懂你的回答,我该怎么办?
  • 尝试从 Project/Gradle 中移除 services 依赖,并在 Project/Gradle 中添加 google() repositories

标签: java android android-studio android-gradle-plugin


【解决方案1】:

这可能是因为播放服务版本不在为 OneSignal:[3.7.1, 3.99.99] 是(您可以在 this commit 看到它):

// Limit upper number (exclusive) to prevent untested versions
static def versionGroupOverrides = [
    'com.google.android.gms': '[10.2.1, 11.7.0)',
    'com.android.support': '[26.0.0, 27.1.0)'
]

所以,尝试将播放服务版本更改为11.7.0

您应该尝试使用OneSignal Gradle Plugin,这有助于使 OneSignal Android SDK 与您的 Android Studio 项目兼容。将 OneSignal-Gradle-Plugin 0.8.0 用于OneSignal:[3.7.1, 3.99.99]

【讨论】:

  • 好的,但以前 com.google.android.gms:play-services-xxx 库是 11.8.0 Onesignal 库是 'com.onesignal:OneSignal:[3.6.2, 3.99.99]' 并且没有问题。
  • 假设 com.google.android.gms:play-services-xxx 库是 11.8.0 'com.onesignal:OneSignal:[3.6.2, 3.99.99]' 存在同样的问题。然后我想,我的问题不在于 Onesignal - 播放服务的兼容性。
  • 您对播放服务兼容性的看法可能是正确的。检查此文件 github.com/OneSignal/OneSignal-Android-SDK/blob/… ,它使用 'com.google.android.gms': '[10.2.1,11.3.0)', 但正如您所说,使用播放服务 11.8.0 不会出现任何错误。
  • 如果您使用播放服务 11.8.0 和一个信号 3.7.1 是否会发生同样的错误?
  • 它是 11.8.0 和 3.6.2,昨天没有问题。但是今天突然出现了同样的错误。 (更多信息github.com/facebook/react-native/issues/18479我不是在原生反应中开发,但我认为这个链接中的原因相同。)所以根据你的链接(你分享了关于兼容性的链接),这似乎是不可能的,但我敢肯定,就是这样。 11.8.0 和 3.6.2 并运行良好不是今天,昨天。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2018-09-04
  • 2018-08-30
  • 2018-12-04
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-06-23
相关资源
最近更新 更多