Reputation: 5897
Suddenly I can no longer build a react native app. The task, mentioned in the question title fails with following message:
* What went wrong:
Execution failed for task ':app:transformClassesWithDexForDebug'.
> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexException: Multiple dex files define Lcom/google/android/gms/internal/zzmu;
My android/build.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.1.2'
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 {
mavenLocal()
jcenter()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
}
}
And dependencies section from android/app/build.gradle
:
dependencies {
compile project(':react-native-keychain')
compile project(':react-native-fbsdk')
compile project(':react-native-randombytes')
compile project(':react-native-barcodescanner')
compile project(':react-native-camera')
compile project(':rn-splash-screen')
compile project(':react-native-code-push')
compile project(':react-native-vector-icons')
compile fileTree(dir: "libs", include: ["*.jar"])
compile "com.android.support:appcompat-v7:23.0.1"
compile "com.facebook.react:react-native:+" // From node_modules
compile(project(":react-native-google-signin")){
exclude group: "com.google.android.gms"
}
compile 'com.google.firebase:firebase-core:9.4.0'
compile 'com.google.android.gms:play-services-auth:9.4.0'
compile project(':react-native-vector-icons')
compile project(':react-native-code-push')
compile project(':react-native-onesignal')
}
I've heard that it occurs due to conflicts (e.g. google play services declared twice, or declared as a particular service in one place and as a whole in another place) But can't figure out what the problem is. What's wrong here and how can I fix it?
Upvotes: 0
Views: 2246
Reputation: 2725
clean gradle then build again.
cd android
then ./gradlew clean
Upvotes: 1
Reputation: 337
My (limited) understanding of Android tells me that you are including seperate dependencies that share a method name in some way or another. I've found these errors to typically point to a version mismatch in my dependency tree - in this case it looks like you have multiple projects depending on com.google.android.gms:play-services-auth
.
The conflicts you've heard of seem to be problem... exclude group
may not be working how you intend.
Take a look inside node_modules/react-native-google-signin/android/build.gradle
and compare the version of play-services-auth
it depends on against the play-services-auth
in your project's app/build.gradle
. Considering your dependency list points at version 9.4.0 you can try setting the react-native-google-signin dependency version to match, or vice-versa.
dependencies {
compile "com.google.android.gms:play-services-auth:9.4.0"
compile "com.facebook.react:react-native:+"
}
Upvotes: 0