Kanwarjeet Singh
Kanwarjeet Singh

Reputation: 745

React Native, Execution failed for task ':app:mergeDexDebug'

I'm trying to run my app in physical device but getting that error. I tried to clean gradlew with cd android and ./gradlew clean. I also tried to clean cache but it's giving that error. I just install the react navigation and stack navigation after that I'm getting that error I also tried to reinstall navigation packages but still getting same error. Can anyone help me please? error and package.json is below

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:mergeDexDebug'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
   > com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives:
     The number of method references in a .dex file cannot exceed 64K.
     Learn how to resolve this issue at https://developer.android.com/tools/building/multidex.html

package.json

"dependencies": {
    "@react-native-community/google-signin": "^5.0.0",
    "@react-native-community/masked-view": "^0.1.10",
    "@react-navigation/native": "^5.8.4",
    "@react-navigation/stack": "^5.12.1",
    "is_js": "^0.9.0",
    "react": "16.13.1",
    "react-native": "^0.63.1",
    "react-native-fbsdk": "^2.0.0",
    "react-native-flash-message": "^0.1.16",
    "react-native-gesture-handler": "^1.8.0",
    "react-native-localization": "^2.1.6",
    "react-native-reanimated": "^1.13.1",
    "react-native-safe-area-context": "^3.1.8",
    "react-native-screens": "^2.12.0",
    "react-native-vector-icons": "^7.1.0",
    "react-native-webview": "^10.10.0"
  },

Upvotes: 6

Views: 9856

Answers (3)

Mohan Nataraj
Mohan Nataraj

Reputation: 51

this could be due to multiple same node files in package.json

also I had an issue with masked-view-community as mentioned above

Upvotes: 0

Justin.Mathew
Justin.Mathew

Reputation: 481

You may have two packages with the same name.

Check your package.json file doesn't have @react-native-community/masked-view and @react-native-masked-view/masked-view

If so remove @react-native-community/masked-view from your pacakge.json file with yarn remove @react-native-community/masked-view

Upvotes: 1

Hend El-Sahli
Hend El-Sahli

Reputation: 6742

According to the Docs

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

You may try enabling multiDex to resolve this issue

In your android/app/build.gradle

defaultConfig {
    /** ... */
    multiDexEnabled true
}

Clean your build and any installed instances in your physical-device as a precaution

Upvotes: 7

Related Questions