Closed nbastoWM closed 8 years ago
i got the same error
rn 0.18.0
Try running ./gradlew app:dependencies
in android
directory in terminal
i found the way to solve this problem. just remove both 'build' folder in /android and /android/app and build again with 'react-native run-android'
Good!
Neither solution worked for me. I even removed the folder node_modules and did npm install
again.
The full error:
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Lcom/google/android/gms/internal/zzlv;
at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596)
at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:554)
at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:535)
at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)
at com.android.dx.merge.DexMerger.merge(DexMerger.java:189)
at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:502)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:334)
at com.android.dx.command.dexer.Main.run(Main.java:277)
at com.android.dx.command.dexer.Main.main(Main.java:245)
at com.android.dx.command.Main.main(Main.java:106)
:app:transformClassesWithDexForDebug FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:transformClassesWithDexForDebug'.
> com.android.build.transform.api.TransformException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/bin/java'' finished with non-zero exit value 2
@nbastoWM
Can you share your project android/build.gradle
and android/app/build.gradle
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:1.3.1'
classpath 'com.google.gms:google-services:1.4.0-beta3' // <- Add this line
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
mavenLocal()
jcenter()
}
}
android/app/build.gradle
apply plugin: "com.android.application"
apply plugin: 'com.google.gms.google-services' // <- Add this line
apply from: "react.gradle"
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.wmmycityapp"
minSdkVersion 16
targetSdkVersion 22
versionCode 1
versionName "1.0"
ndk {
abiFilters "armeabi-v7a", "x86"
}
}
buildTypes {
release {
minifyEnabled false // Set this to true to enable Proguard
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
}
}
}
dependencies {
compile project(':react-native-google-analytics-bridge')
compile fileTree(dir: "libs", include: ["*.jar"])
compile "com.android.support:appcompat-v7:23.0.1"
compile "com.facebook.react:react-native:0.17.+"
compile project(':reactnativemapboxgl')
compile project(':react-native-image-picker')
compile project(':react-native-icons')
compile project(':RNDeviceInfo')
compile project(':react-native-contacts')
compile project(':reactdate')
compile "com.google.android.gms:play-services-gcm:8.1.0" // <- Add this line
compile project(':RNGcmAndroid') // <- Add this line
compile project(':react-native-system-notification') // <- Add this line
}
I got it running by changing to:
compile "com.google.android.gms:play-services-gcm:8.3.0"
and
classpath 'com.google.gms:google-services:1.5.0-beta3'
Good! This solution will help many people that encounter this issue.
Yup ! I had faced the same issue, @nbastoWM solution worked pretty well. Can I update the Readme, if there is no compatible problem with play-services-gcm:8.3.0 and google-services:1.5.0-beta3 ?
@vikassy Please do it, thanks.
@nbastoWM - I made those changes, but I'm still only able to build the app with multiDexEnabled = true
. I tried deleting both of my build folders and updating those two packages, but nothing seems to work except multiDexEnabled = true
. Is there anything else that you may have done to get past this issue that you're leaving out?
@lynndylanhurley I'm not sure but you may try to delete android/app/src/main/assets/index.android.bundle
. Let me know if it doesn't work.
I'm having the same issue. @lynndylanhurley Did you find any solutions?
@oney I tried to run the project without compile "com.google.android.gms:play-services-gcm:8.3.0"
and classpath 'com.google.gms:google-services:1.5.0-beta3'
but I still get the same error.
Do you think this has to do with the GCM libraries or with your code?
I just had to set multiDexEnabled = true
. I don't really understand the implications, but people seem to discourage it. But it hasn't caused me any problems.
i found the way to solve this problem. just remove both 'build' folder in /android and /android/app and build again with 'react-native run-android'
@notlose thanks you! I struggled with this issue for two hours! This fixed it!
@notlose Solution work for me! ( I am using React Native 0.51 )
after remove both /android/build
and /android/app/build
and re-run
cd android && ./gradlew assembleRelease
Had the same issue and the solution that worked for me was to add this to my build.gradle
:
dexOptions { jumboMode true }
I also added dex.force.jumbo=true
to my gradle.properties
just to be sure. Seems like that did the magic.
Error:Execution failed for task ':app:transformClassesWithDexBuilderForDebug'.
com.android.build.api.transform.TransformException: java.lang.IllegalStateException: Dex archives: setting .DEX extension only for .CLASS files this error in my app please help my
Try adding this in your android/app/build.gradle
configurations.all {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
if (details.getRequested().getGroup() == 'com.google.android.gms') {
details.useVersion('9.8.0')
}
}
}
In my case gradle was not in the environment variables. Check in terminal for the command gradle. If not recognized first you have to find the folder of gradle in configuration> settings> build of the android studio. The bin is added to the environment variables. Check again the gradle word in terminal later it runs ./gradlew in unix like systems from the terminal or .\ gradlew in the powershell of windows
If java 8 or above is used then the problem is the libraries we use are incompatible with java 8. So to solve this add these two lines to build.gradle of your app and all sub modules if any. (Android studio clearly show how to do this in error message)
targetCompatibility = '1.7' sourceCompatibility = '1.7'
Below lines works for me,
compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 }
there's no need to remove "build" folders manually, just run "gradlew clean" command in android folder.
@MaheshNandam In what file did you add those lines?
@sturmenta , it's in android/app/build.gradle
Work to me react-native init projectwebrtc cd projectwebrtc npm i -s react-native-webrtc react-native link react-native-webrtc
and in android/app/build.gradle add inside android section:
compileOptions { sourceCompatibility = '1.8' targetCompatibility = '1.8' }
remove android folder run
react-native upgrade
then
react-native run-android
This worked for me after 4 hours of trying, by adding this to the module dependencies :
dependencies {
configurations {
all*.exclude group: 'com.android.support', module: 'support-v13'
}
....
}
I hope this helps 👍
If you are running on Terminal, check if the java version you are using is 1.8.
$ java -version
depending on gradle version you might have issues with java 1.8+
So, install the 1.8 version and change the JAVA_PATH
to:
export JAVA_HOME="$(/usr/libexec/java_home -v 1.8)"
Make sure it's on your PATH
as well
Please tell me where I need to enter the command 'react-native run-android' ?
i found the way to solve this problem. just remove both 'build' folder in /android and /android/app and build again with 'react-native run-android'
Very good!
If your minSdkVersion is lower then 21 you need to add multiDexEnabled = true
on app/build.gradle
reference: https://developer.android.com/studio/build/multidex
If your minSdkVersion is lower then 21 you need to add
multiDexEnabled = true
onapp/build.gradle
reference: https://developer.android.com/studio/build/multidex
help full for me
Deleting build folders didnot solve my issue
I need to delete some hidden folders too. Change settings to view hidden folders ( cmd +shift + . in mac)
Delete build, .gradlew, .idea, files with .iml in android folder Delete build folder in android/app
Now go back and run react-native run-android
Good luck :)
In app/build.gradle add
defaultConfig{
...
multiDexEnabled true //add this
}
Refer this
android { defaultConfig { ... minSdkVersion 21 targetSdkVersion 26 multiDexEnabled true <---- Add this } ... }
Hey everyone! I am getting this error when generating release apk, in debug works fine
> Task :app:mergeDexRelease FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:mergeDexRelease'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> java.lang.OutOfMemoryError (no error message)
I'm using react-native-maps and my issue was Execution failed for task ':app:mergeDexDebug'.
I solved by editing the app/build.gradle:
android {
defaultConfig {
// ...
multiDexEnabled true
}
// ...
}
Thanks @Darkensses this worked. I wonder why the tooling does not enable this by default. But I guess it would prevent the app from running on very old Android devices? With this setting it runs on my baseline Android 5 device without problems.
I got the same error after using react-native-firebase
SDK but after adding multiDexEnabled true
inside android/app/build.gradle
it's work for me Thanks @lynndylanhurley
Just delete android/.gradle
and 'android/app/build'.
Reasons for the issue.
I just had to set
multiDexEnabled = true
. I don't really understand the implications, but people seem to discourage it. But it hasn't caused me any problems.
Thanks alot this worked! <3
I tried to run the example and everything went OK. When I tried to install this module onto my App, that error appears.
I don't have multiDexEnabled and I'm running on an Android device with RN 0.17.