0

I have problem with running RN Android app using react-native run-android

It throws exception at the build stage and can't figure out the issue.

Execution failed for task ':react-native-firebase:transformClassesWithDexForDebugAndroidTest'.
> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536

I've tried various solutions on the web and it was all in vein. Tried solutions were enabling multiDex and increase the javaMaxHeapSize in dexOptions.

This error can be seen as a library or component dependent, but it happens for any kind of apps which exceeds 64k limits.

One more thing: It compiles without any problem in Android Studio

Tom Aranda
  • 5,919
  • 11
  • 35
  • 51
Daniel Zheng
  • 304
  • 1
  • 9
  • Have you tried [enabling jumbo mode](https://github.com/zo0r/react-native-push-notification/issues/328) (first hit on Google)? – Tom Aranda Dec 05 '17 at 15:25

2 Answers2

5

With react 0.60 I was having this issue, and adding multiDexEnabled true to my defaultConfig (android/app/build.gradle) fixed it:

android {
    ...
    defaultConfig {
        ...
        multiDexEnabled true
   }
   ...
}
Tiago Gouvêa
  • 15,036
  • 4
  • 75
  • 81
0

You have too many methods by the look of it. This a common DEX issue. As mentioned here:

DexIndexOverflowException issue after updating to latest appcompat and support library

Add this to your build.gradle:

android {

  defaultConfig {
    ...

    // Enabling multidex support.
    multiDexEnabled true
  }
  ...
}

dependencies {
  compile 'com.android.support:multidex:1.0.1'
}

Then in your Android Manifest add this:

<?xml version="1.0" encoding="utf-8"?>
  <manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.android.multidex.myapplication">
    <application
      ...
      android:name="android.support.multidex.MultiDexApplication"> 
      ...
    </application>
</manifest>

Let me know if this helps! I have come across this issue before myself.

ShaneG
  • 1,498
  • 7
  • 16