0

I have a React Native application, that runs fine on iOS, I tried to run it on Android too, but I always get the error:

error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup. Run CLI with --verbose flag for more details.
Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081
D8: Cannot fit requested classes in a single dex file (# methods: 116691 > 65536 ; # fields: 80012 > 65536)

I tried every solution I saw, nothing worked.

I ran the react-native-community cli doctor and it seems like React Native won't recognize the Android SDK. I checked, and the emulator sdk and the gradle sdk versions are the same. echoing ANDROID_HOME on the terminal properly gives me the sdk path, I followed the React Native getting started again to see if I missed something, but it seems like everything is install correctly.

I can't figure out why this won't run.

2
  • Have you tested a “hello world” apps a sanity check? The complaint about class size means it appears to be trying to run. Commented Sep 19, 2020 at 11:40
  • @DaveNewton Yes, I have the application running great on iOS, on Android I can't run it. I also tried to run native Android application, to check if everything really installed properly, I have no problem running a native app. Commented Sep 19, 2020 at 11:46

1 Answer 1

1

In your android\app\build.gradle try adding

android {
    ...
    defaultConfig {
        ...
        multiDexEnabled true
   }
}
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.