React Native 0.70.1 Build in debug Mode, when i try to build in release mode, I get the below error.error message.
My package.json
{
"name": "xxxxxx",
"version": "0.0.1",
"private": true,
"scripts": {
"android": "react-native run-android",
"ios": "react-native run-ios",
"start": "react-native start",
"test": "jest",
"lint": "eslint ."
},
"dependencies": {
"@react-navigation/native": "^6.1.1",
"@react-navigation/native-stack": "^6.9.6",
"moment": "^2.29.4",
"react": "18.1.0",
"react-native": "0.70.6",
"react-native-image-picker": "^4.10.2",
"react-native-paper": "^5.0.1",
"react-native-raw-bottom-sheet": "^2.2.0",
"react-native-safe-area-context": "^4.5.0",
"react-native-screens": "^3.18.0",
"react-native-svg": "^13.7.0",
"react-native-vector-icons": "^9.2.0",
"rtn-fetch-module": "file:RTNFetchModule"
},
"devDependencies": {
"@babel/core": "^7.12.9",
"@babel/runtime": "^7.12.5",
"@react-native-community/eslint-config": "^2.0.0",
"babel-jest": "^26.6.3",
"eslint": "^7.32.0",
"jest": "^26.6.3",
"metro-react-native-babel-preset": "0.72.3",
"react-native-svg-transformer": "^1.0.0",
"react-test-renderer": "18.1.0"
},
"jest": {
"preset": "react-native"
}
}
I am trying to build react-native in release mode.
CodePudding user response:
To fix this issue, you can try using the --minimize-warning
flag when building the release version of the app, or try using a tool like react-native-clean-project
to remove duplicated dependencies. Additionally, you can try to check your dependencies and see if there is any duplicate libraries or classes that you can remove.
CodePudding user response:
Add multidex in /android/app/build.gradle file
android {
defaultConfig {
// ...
multiDexEnabled true // <-- ADD THIS in the defaultConfig section
}
// ...
}
dependencies {
implementation 'androidx.multidex:multidex:2.0.1' // <-- ADD THIS DEPENDENCY
}
Then in android/app/src/main/java/.../MainApplication.java
// ... all your other imports here
import androidx.multidex.MultiDexApplication; // <-- ADD THIS IMPORT
// Your class definition needs `extends MultiDexApplication` like below
public class MainApplication extends MultiDexApplication implements ReactApplication {
Once added, rebuild your application: npx react-native run-android.