react-native-background-geolocation: duplicate entry: com/google/android/gms/auth/api/signin/zzc.class

Your Environment

  • Plugin version: 2.9.4
  • Platform: Android
  • OS version: Android 8.0
  • Device manufacturer / model: Pixel Simulator
  • React Native version (react-native -v): 0.49.3
  • Plugin config
  • Expo Version: 22.0.0

Expected Behavior

Link library to android ap and run.

Actual Behavior

Unable to run app due to duplicate dependencies.

Steps to Reproduce

  1. Detach working expo app
  2. Tested Android app before linking library
  3. Link Library base on https://github.com/transistorsoft/react-native-background-geolocation/blob/master/docs/INSTALL-ANDROID-RNPM.md .
  4. Run from Android Studios

Context

I have been reviewing posts like the following hoping to make sense of the error.

https://github.com/transistorsoft/react-native-background-geolocation/issues/244 https://github.com/transistorsoft/react-native-background-geolocation/issues/229

Debug logs

Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
> com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/android/gms/auth/api/signin/zzc.class

Build.Gradle File

apply plugin: 'com.android.application'

android {
	compileSdkVersion 25
	buildToolsVersion '25.0.2'

	defaultConfig {
		applicationId "com.thirtyEigthSS.FCEChauffeur"
		minSdkVersion 19
		targetSdkVersion 25
		versionCode 1
		versionName "1.0"
		multiDexEnabled true
		ndk {
			abiFilters 'armeabi-v7a', 'x86'
		}
		manifestPlaceholders = [
			'appAuthRedirectScheme': 'com.thirtyEigthSS.FCEChauffeur'
		]
	}
	buildTypes {
		release {
			minifyEnabled false
			proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
		}
	}
	dexOptions {
		javaMaxHeapSize "8g"
	}
	lintOptions {
		abortOnError false
	}
}

task exponentPrebuildStep(type: Exec) {
	workingDir '../../'

	if (System.getProperty('os.name').toLowerCase().contains('windows')) {
		commandLine 'cmd', '/c', '.\\.expo-source\\android\\detach-scripts\\prepare-detached-build.bat'
	} else {
		commandLine './.expo-source/android/detach-scripts/prepare-detached-build.sh'
	}
}
preBuild.dependsOn exponentPrebuildStep

repositories{
	flatDir{
		dirs 'libs'
	}
	mavenLocal()
	maven { url 'https://maven.fabric.io/public' }
}

repositories {
	flatDir {
		dirs "../../node_modules/react-native-background-geolocation/android/libs"
	}
}

dependencies {
    compile project(':react-native-background-geolocation')
	compile fileTree(dir: 'libs', include: ['*.jar'])
	testCompile 'junit:junit:4.12'
	compile 'com.android.support:appcompat-v7:25.3.1'
	compile 'com.android.support:multidex:1.0.1'

	compile('host.exp.exponent:expoview:22.0.0@aar') {
		exclude group: 'com.facebook.android', module: 'facebook-android-sdk'
		exclude group: 'com.facebook.android', module: 'audience-network-sdk'
		exclude group: 'io.nlopez.smartlocation', module: 'library'
		transitive = true;
	}

	compile ('com.facebook.android:facebook-android-sdk:4.+') {
		exclude module: 'bolts-android'
	}
	compile('com.facebook.android:audience-network-sdk:4.+') {
		exclude module: 'play-services-ads'
	}
	compile('io.nlopez.smartlocation:library:3.2.11') {
		transitive = false
	}
	compile(name: 'tslocationmanager', ext: 'aar')
}

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 20 (9 by maintainers)

Most upvoted comments

With latest version coming soon, you’ll need to use minimum 11.2.0.

Latest play-services version (released Nov 6) is 11.6.0. It’s always preferable to use latest version.

Wanted to post my working build.gradle file. See all lines with ‘//Added this’

apply plugin: 'com.android.application'

android {
	compileSdkVersion 25
	buildToolsVersion '25.0.2'

	defaultConfig {
		applicationId "com.thirtyEigthSS.FCEChauffeur"
		minSdkVersion 19
		targetSdkVersion 25
		versionCode 1
		versionName "1.0"
		multiDexEnabled true
		ndk {
			abiFilters 'armeabi-v7a', 'x86'
		}
		manifestPlaceholders = [
			'appAuthRedirectScheme': 'com.thirtyEigthSS.FCEChauffeur'
		]
	}
	buildTypes {
		release {
			minifyEnabled false
			proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
		}
	}
	dexOptions {
		javaMaxHeapSize "8g"
	}
	lintOptions {
		abortOnError false
	}
	//Added This
	packagingOptions {
		exclude 'META-INF/maven/com.squareup.okhttp3/okhttp/pom.properties'
		exclude 'META-INF/maven/com.squareup.okio/okio/pom.xml'
		exclude 'META-INF/maven/com.squareup.okhttp3/okhttp/pom.xml'
		exclude 'META-INF/maven/com.squareup.okio/okio/pom.properties'
	}
	//End - Added This
}

task exponentPrebuildStep(type: Exec) {
	workingDir '../../'

	if (System.getProperty('os.name').toLowerCase().contains('windows')) {
		commandLine 'cmd', '/c', '.\\.expo-source\\android\\detach-scripts\\prepare-detached-build.bat'
	} else {
		commandLine './.expo-source/android/detach-scripts/prepare-detached-build.sh'
	}
}
preBuild.dependsOn exponentPrebuildStep

repositories{
	flatDir{
		dirs 'libs'
		dirs "../../node_modules/react-native-background-geolocation/android/libs"
	}
	mavenLocal()
	maven { url 'https://maven.fabric.io/public' }
}


dependencies {
	compile fileTree(dir: 'libs', include: ['*.jar'])
	testCompile 'junit:junit:4.12'
	compile 'com.android.support:appcompat-v7:25.3.1'
	compile 'com.android.support:multidex:1.0.1'

	compile('host.exp.exponent:expoview:22.0.0@aar') {
		exclude group: 'com.facebook.android', module: 'facebook-android-sdk'
		exclude group: 'com.facebook.android', module: 'audience-network-sdk'
		exclude group: 'io.nlopez.smartlocation', module: 'library'

		exclude group: 'com.google.android.gms'  //Added This

		transitive = true;
	}

	//Added This
	compile ("com.google.android.gms:play-services-base:11.0.4") {
		force = true;
	}
	compile ("com.google.android.gms:play-services-maps:11.0.4") {
			force = true;
	}
	compile ("com.google.android.gms:play-services-gcm:11.0.4") {
			force = true;
	}
	compile ("com.google.android.gms:play-services-location:11.0.4") {
			force = true;
	}
	compile ("com.google.android.gms:play-services-auth:11.0.4") {
			force = true;
	}
	compile ("com.google.android.gms:play-services-analytics:11.0.4") {
			force = true;
	}
	compile ("com.google.android.gms:play-services-ads:11.0.4") {
			force = true;
	}
	compile ('com.google.android.gms:play-services-wallet:11.0.4') {
			force = true;
	}
	//End - Added This

	compile ('com.facebook.android:facebook-android-sdk:4.+') {
		exclude module: 'bolts-android'
	}
	compile('com.facebook.android:audience-network-sdk:4.+') {
		exclude module: 'play-services-ads'
	}
	compile('io.nlopez.smartlocation:library:3.2.11') {
		transitive = false
	}

	compile(name: 'tslocationmanager', ext: 'aar') 
	compile(project(':react-native-background-geolocation')) 
}