joonhocho / react-native-google-sign-in

React Native Wrapper for Latest Google Sign-In OAuth SDK / API
MIT License
211 stars 65 forks source link

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

Open mastersam92 opened 6 years ago

mastersam92 commented 6 years ago

Got strange error while build for Android: Execution failed for task ':react-native-google-sign-in:processReleaseResources'. Error: more than one library with package name 'com.google.android.gms.license'

All steps completed. A few days ago, all was fine( no errors ).

Any ideas ?

mastersam92 commented 6 years ago

Solved: https://github.com/facebook/react-native/issues/18479

MasahiroMorita commented 6 years ago

How have you solved? I'm still facing this problem...

My android/build.gradle:

buildscript {
    repositories {
        jcenter()
        google()
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.1'
        classpath 'com.google.gms:google-services:3.2.0'
    }
}

allprojects {
    repositories {
        mavenLocal()
        jcenter()
        maven {
            url "$rootDir/../node_modules/react-native/android"
        }
        maven {
            url "https://maven.google.com"
        }
    }
}

// see: https://github.com/facebook/react-native/issues/18479
ext {
    googlePlayServicesVersion = '11.8.0'
    compileSdkVersion = 27
    buildToolsVersion = '27.0.3'
    supportLibrariesVersion = '27.1.0'
}
subprojects { subproject ->
    afterEvaluate{
        if((subproject.plugins.hasPlugin('android') || subproject.plugins.hasPlugin('android-library'))) {
            android {
                compileSdkVersion rootProject.ext.compileSdkVersion
                buildToolsVersion rootProject.ext.buildToolsVersion
            }
        }
    }
}

And android/app/build.gradle:

android {
    compileSdkVersion project.compileSdkVersion
    buildToolsVersion project.buildToolsVersion
    defaultConfig {
        applicationId "...."
        minSdkVersion 19
        targetSdkVersion 27
        versionCode 17
        versionName "2.0.10"
        ndk {
            abiFilters "armeabi-v7a", "x86"
        }
        vectorDrawables.useSupportLibrary = true
        multiDexEnabled true
    }
    dexOptions {
        javaMaxHeapSize "4g"
    }
    ...
}
...
dependencies {
    implementation 'com.android.support:multidex:1.0.1'
    implementation project(':react-native-share')
    implementation project(':react-native-restart')
    implementation project(':react-native-exception-handler')
    implementation project(':react-native-zendesk-support')
    implementation project(':react-native-code-push')
    implementation project(':react-native-push-notification')
    implementation project(':react-native-image-crop-picker')
    implementation(project(':react-native-google-sign-in')) { // ADD this
        exclude group: "com.google.android.gms"
    }
    implementation project(':react-native-vector-icons')
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation "com.android.support:appcompat-v7:$project.supportLibrariesVersion"
    implementation "com.google.android.gms:play-services-auth:$project.googlePlayServicesVersion"
    implementation("com.google.android.gms:play-services-gcm:$project.googlePlayServicesVersion") {
        force = true;
    }
    implementation 'com.facebook.react:react-native:+'
    implementation project(':react-native-video')
    implementation project(':react-native-s3')
}
mastersam92 commented 6 years ago

@MasahiroMorita,

Whats error ?

My configs is( maybe, it isn't optimal config.. Just, it first variant, that works for me :) :

android/build.gradle:

def googlePlayServicesVersion = '11.8.0'

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.2.3'
        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 {
        // google()
        mavenLocal()
        jcenter()
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url "$rootDir/../node_modules/react-native/android"
        }

        configurations.all {
            resolutionStrategy {
                force 'com.facebook.android:facebook-android-sdk:4.22.1'
            }
        }
        maven {
            url "https://maven.google.com"
        }
        maven { url "https://jitpack.io" }

        configurations.all {
            resolutionStrategy {
                // force "com.google.android.gms:play-services:11.8.0"
                 // react-native-admob
                 force "com.google.android.gms:play-services-ads:$googlePlayServicesVersion"
                 // react-native-maps
                 force "com.google.android.gms:play-services-base:$googlePlayServicesVersion"
                 force "com.google.android.gms:play-services-maps:$googlePlayServicesVersion"
                 // react-native-onesignal
                 force "com.google.android.gms:play-services-gcm:$googlePlayServicesVersion"
                 force "com.google.android.gms:play-services-analytics:$googlePlayServicesVersion"
                 force "com.google.android.gms:play-services-location:$googlePlayServicesVersion"
                 // react-native-google-sign-in
                 force "com.google.android.gms:play-services-auth:$googlePlayServicesVersion"
            }
        }
    }
}

And android/app/build.gradle:

apply plugin: "com.android.application"

import com.android.build.OutputFile

project.ext.react = [
    entryFile: "index.js"
]

apply from: "../../node_modules/react-native/react.gradle"

apply plugin: 'com.android.application'

def enableSeparateBuildPerCPUArchitecture = false

def enableProguardInReleaseBuilds = false

android {
    compileSdkVersion 26
    buildToolsVersion "26.0.1"

    defaultConfig {
        applicationId "..."
        minSdkVersion 16
        targetSdkVersion 22
        versionCode 2
        versionName "1.0"
        ndk {
            abiFilters "armeabi-v7a", "x86"
        }
        vectorDrawables.useSupportLibrary = true
        multiDexEnabled true
    }

    ...
}

dependencies {
    compile 'com.android.support:multidex:1.0.1'
    compile(project(":react-native-google-sign-in")) {
        exclude group: "com.google.android.gms"
    }
    compile project(':react-native-fbsdk')
    compile project(':react-native-twitter-signin')
    compile project(':react-native-image-crop-picker')
    compile fileTree(dir: "libs", include: ["*.jar"])
    compile "com.android.support:appcompat-v7:23.0.1"

    compile "com.google.android.gms:play-services-auth:11.8.0"
    compile "com.facebook.react:react-native:+"  // From node_modules

    compile 'com.google.android.gms:play-services-base:11.8.0'
    compile 'com.google.android.gms:play-services-wallet:11.8.0'
}

apply plugin: "com.google.gms.google-services"

task copyDownloadableDepsToLibs(type: Copy) {
    from configurations.compile
    into 'libs'
}