Error: more than one library with package name 

2019-08-16 05:49发布

问题:

Today, I opened Android Studio, then I get this error. Yesterday, there was a no problem such that!

Error:Execution failed for task ':app:processDebugResources'.

Error: more than one library with package name 'com.google.android.gms.license'

com.google.android.gms:play-services-xxx libraries was

11.8.0

Onesignal library was

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

Then I changed them to latest version.

Now App/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'

Project/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()
    }
}

But I am still getting same error that stated above. How can I solve this problem? Why did this problem occur Today when there was no problem, yesterday?

回答1:

This probably because the play services version is not in the range defined for OneSignal:[3.7.1, 3.99.99] which is (you can see it at 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)'
]

So, try changing the play services version to 11.7.0.

You should try using OneSignal Gradle Plugin which helps make the OneSignal Android SDK compatible with your Android Studio project. Use OneSignal-Gradle-Plugin 0.8.0 for OneSignal:[3.7.1, 3.99.99]