我尝试在物理设备中运行我的应用程序,但收到该错误。我尝试用
cd android
和 ./gradlew clean
清理 gradlew。我也尝试清理缓存,但它给出了该错误。我只是安装了反应导航和堆栈导航,之后我收到了该错误,我也尝试重新安装导航包,但仍然收到相同的错误。有人可以帮我吗?错误,package.json 如下
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"
},
根据文档
当您的应用及其引用的库超过 65,536 个方法时,您会遇到构建错误,表明您的应用已达到 Android 构建架构的限制
您可以尝试启用
multiDex
来解决此问题
在你的 android/app/build.gradle 中
defaultConfig {
/** ... */
multiDexEnabled true
}
作为预防措施,请清理您的构建以及物理设备中所有已安装的实例
您可能有两个同名的包。
检查您的 package.json 文件没有
@react-native-community/masked-view
和 @react-native-masked-view/masked-view
如果是这样,请使用
@react-native-community/masked-view
从 pacakge.json 文件中删除
yarn remove @react-native-community/masked-view