React Native multidex error: The number of method references in a .dex file cannot exceed 64K
I am writing this blog to share a quick solution to this problem to save the time of many beginners who are setting up react native first time. I have spent more than 20 min to fix this issue.
I have seen this error while setting up react-native app with the react-native-navigation module.
After debugging and going through the many blogs, found this may not be related to the react-native navigation module and looks not even related to react-native. Anybody may hit this issue who is developing an android app regardless of any technology like JAVA , Kotlin, react-native etc..
Look at this official google android app doc
When your app and the libraries it references exceed 65,536 methods, you encounter a build error that indicates your app has reached the limit of the Android build architecture:
The error will look like this-
Solution
go to /android/app/build.gradle and add the below parameter value and module.
android {...
defaultConfig {multiDexEnabled true}dependencies {...
implementation 'com.android.support:multidex:1.0.3'}
}
Once you added, rerun the below command, this should solve your problem.
npx react-native run-android
Enjoy!
If you still face the issue, please drop a comment.