gradle 我无法在发布模式下生成React本机项目

scyqe7ek  于 2023-01-26  发布在  React
关注(0)|答案(1)|浏览(96)

React Native 0.70.1在调试模式下构建,当我尝试在发布模式下构建时,我得到以下错误。error message
我的软件包. 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"
  }
}

我正在尝试在发布模式下构建react-native。

ddarikpa

ddarikpa1#

在**/android/app/build.gradle**文件中添加多索引

android {
defaultConfig {
    // ...
    multiDexEnabled true // <-- ADD THIS in the defaultConfig section
}
// ...
}

dependencies {
  implementation 'androidx.multidex:multidex:2.0.1'  // <-- ADD THIS DEPENDENCY
}

然后在安卓/应用程序/源代码/主/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 {

添加后,重新生成应用程序:npxReact-本机运行-安卓。

相关问题