RN react-native run-android运行报错

本文详细解析了在React Native项目中遇到的构建失败问题,主要原因是JDK环境变量配置错误导致的异常。文章提供了错误日志分析,指出问题出现在E盘的ReactNative项目中的build.gradle文件,并最终确定为JDK版本冲突所致。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

FAILURE: Build failed with an exception.

  • Where:
    Build file ‘E:\ReactNative\FirstRNProject\android\app\build.gradle’ line: 1

  • What went wrong:
    A problem occurred evaluating project ‘:app’.

Uninitialized object exists on backward branch 70
Exception Details:
Location:
com/android/build/gradle/internal/scope/BuildArtifactsHolder.newArtifact(Lcom/android/build/api/artifact/BuildableArtifact;)Lcom/android/build/gradle/internal/scope/BuildArtifactsHolder$BuildableArtifactData; @119: goto
Reason:
Error exists in the bytecode
Bytecode:
0000000: bb02 0559 2bb9 0208 0100 c000 b82b b902
0000010: 0c01 0001 b902 1202 0059 1302 14b8 0051
0000020: c001 734d 3a0d 3a0c 3a0b 2c4e bb01 a659
0000030: 2c10 0ab8 0177 b701 a7c0 00b8 3a04 2db9
0000040: 018e 0100 3a05 1905 b901 9401 0099 002d
0000050: 1905 b901 9801 003a 0619 0419 06c0 00f1
0000060: 3a07 3a0e 1907 b902 1501 003a 0f19 0e19
0000070: 0fb9 01ad 0200 57a7 ffcf 1904 c001 af3a
0000080: 0e19 0b19 0c19 0d19 0eb7 0218 b0
Stackmap Table:
full_frame(@70,{Object[#2],Object[#83],Object[#371],Object[#371],Object[#184],Object[#400],Top,Top,Top,Top,Top,Uninitialized[#0],Uninitialized[#0],Object[#184]},{})
same_frame(@122)

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Get more help at https://help.gradle.org

BUILD FAILED in 1s
Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/getting-started.html

Command failed: gradlew.bat installDebug

Error: Command failed: gradlew.bat installDebug
at checkExecSyncError (child_process.js:602:13)
at Object.execFileSync (child_process.js:622:13)
at runOnAllDevices (E:\ReactNative\FirstRNProject\node_modules\react-native\local-cli\runAndroid\runAndroid.js:299:19)
at buildAndRun (E:\ReactNative\FirstRNProject\node_modules\react-native\local-cli\runAndroid\runAndroid.js:135:12)
at isPackagerRunning.then.result (E:\ReactNative\FirstRNProject\node_modules\react-native\local-cli\runAndroid\runAndroid.js:65:12)
at
at process._tickCallback (internal/process/next_tick.js:189:7)

问题解决:
JDK变量引错了,电脑里装了多个jdk,环境变量引错了

{ "name": "AwesomeProject", "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 .", "postinstall": "patch-package", "generate:icons": "node generateIconMap.js" }, "dependencies": { "@ant-design/icons-react-native": "^2.3.2", "@ant-design/react-native": "^5.1.0", "@react-native-async-storage/async-storage": "^1.19.0", "@react-native-community/cameraroll": "^4.0.0", "@react-native-community/masked-view": "0.1.11", "@react-native-community/segmented-control": "^2.1.1", "@react-native-community/slider": "^3.0.3", "@react-native-community/viewpager": "^4.1.6", "@react-native-picker/picker": "^1.16.8", "@react-navigation/native": "^6.1.7", "@react-navigation/native-stack": "^6.9.12", "@rneui/base": "^4.0.0-rc.8", "@rneui/themed": "^4.0.0-rc.8", "d3-shape": "^1.3.7", "minio": "^7.0.15", "react": "17.0.2", "react-native": "0.68.0", "react-native-background-timer": "^2.4.1", "react-native-device-info": "^8.1.3", "react-native-elements": "^1.2.7", "react-native-exception-handler": "^2.10.10", "react-native-fs": "^2.18.0", "react-native-gesture-handler": "2.14.0", "react-native-get-location": "^2.1.0", "react-native-get-random-values": "^1.4.0", "react-native-image-picker": "^3.8.1", "react-native-image-zoom-viewer": "^3.0.1", "react-native-linear-gradient": "^2.8.3", "react-native-modal-dropdown": "^1.0.2", "react-native-permissions": "3.8.0", "react-native-reanimated": "2.14.4", "react-native-safe-area-context": "3.3.2", "react-native-screens": "3.15.0", "react-native-signature-capture": "^0.4.12", "react-native-sound": "^0.11.1", "react-native-sqlite-storage": "^4.1.0", "react-native-svg-charts": "5.4.0", "react-native-table-component": "^1.2.2", "react-native-vector-icons": "^9.2.0", "react-native-webview": "^11.26.0", "react-redux": "^7.2.0", "redux": "^4.0.5", "redux-thunk": "^2.3.0" }, "devDependencies": { "@babel/core": "^7.12.9", "@babel/runtime": "^7.12.5", "@react-native-community/cli-doctor": "^10.0.0", "@react-native-community/eslint-config": "^2.0.0", "@react-navigation/native": "^6.1.7", "@react-navigation/native-stack": "^6.9.12", "babel-jest": "^26.6.3", "babel-plugin-import": "^1.13.8", "eslint": "^7.32.0", "jest": "^26.6.3", "metro-react-native-babel-preset": "^0.68.0", "patch-package": "^6.4.7", "react-native-version-check": "^3.5.0", "react-test-renderer": "17.0.2" }, "jest": { "preset": "react-native" } } 这是我的json文件按照你说的降级 降级 @ant-design/react-native 到5.0.1是否有其他报错
最新发布
08-01
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值