Execution failed for task ':app:transformClassesWithDexForDebug' in react native

My guess is you are over the 64k reference limit and need to enable multidexing. The second article you linked referenced how to solve this, but many react-native projects are initialized with minSdkVersion of 16, so there is an extra step to enabled multidex. You have two options.

Option 1:

Upgrade your minSdkVersion to 21 in your AndroidManifest.xml file (android/app/src/main/AndroidManifest.xml) and also your build.gradle file (android/app/build.gradle), then in your build.gradle file add multiDexEnabled to true in this line

android {
    defaultConfig {
        ...
        minSdkVersion 21 
        targetSdkVersion 26
        multiDexEnabled true
    }
    ...
} 

Option 2:

If you need to stay at minSdkVersion 16, set multiDexEnabled to true in your build.gradle file, then add this line under "dependencies" in the same file

dependencies {
  compile 'com.android.support:multidex:1.0.1'
  ...(your other dependencies here)
}

Then depending on whether you override the Application class, perform one of the following:

If you do not override the Application class, edit your manifest file to set android:name in the tag as follows:

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

If you do override the Application class in android/app/src/main/java/MainApplication.java, change it to extend MultiDexApplication (if possible) as follows:

public class MyApplication extends MultiDexApplication { ... }

Here is android's documentation on what this error means and why it occurs, as well as how to fix it https://developer.android.com/studio/build/multidex.html


This worked for me, when you're inside your project directory try using:

cd android && gradlew clean
cd .. && react-native run-android

Source: https://github.com/facebook/react-native/issues/10367#issuecomment-308153481