Skip to content

Instantly share code, notes, and snippets.

@blackinitial
Last active June 8, 2020 13:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save blackinitial/520b6ee42295982ef497b639d3160e14 to your computer and use it in GitHub Desktop.
Save blackinitial/520b6ee42295982ef497b639d3160e14 to your computer and use it in GitHub Desktop.
Fix error react native run-android multidex issue

Error:

cd android && ./gradlew build --warning-mode=all
...
FAILURE: Build failed with an exception.
 
* What went wrong:
Execution failed for task ':app:transformClassesWithDexBuilderForDebug'.
> There was a failure while executing work items
   > A failure occurred while executing com.android.build.gradle.internal.transforms.DexArchiveBuilderTransform$DexConversionWorkAction
      > Failed to process /home/blint/www/react-native/MyDoctor/android/app/build/intermediates/javac/debug/classes
...

Fix:

  • add multidex true on /android/app/build.gradle
    android {
    ...
      defaultConfig {
            ...
            minSdkVersion rootProject.ext.minSdkVersion
            targetSdkVersion rootProject.ext.targetSdkVersion
            multiDexEnabled true
      ...
    
  • uncomment org.gradle.jvmargs=-Xmx2048m... on /android/gradle.properties
    ...
    # Specifies the JVM arguments used for the daemon process.
    # The setting is particularly useful for tweaking memory settings.
    # Default value: -Xmx10248m -XX:MaxPermSize=256m
    org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
    ...
    
  • remove build folder on /android/app/build/
  • rerun npx react-native run-android or ./gradlew build
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment