android - react 原生无法构建Android APK。 gradlew clean和…命令失败

标签 android react-native gradle react-native-cli

"@babel/core": "^7.5.5",
    "@babel/runtime": "^7.5.5",
    "@react-native-community/eslint-config": "^0.0.5",
    "babel-jest": "^24.8.0",
    "eslint": "^6.1.0",
    "jest": "^24.8.0",
    "metro-react-native-babel-preset": "^0.55.0",
    "react-test-renderer": "16.8.6"

我安装了启动React Native项目所需的全部工具。现在当我运行react-native run-android时,它无法运行该项目,并因以下错误而失败:
* What went wrong:
A problem occurred configuring project ':app'.
> Failed to notify project evaluation listener.
   > Uninitialized object exists on backward branch 142
     Exception Details:
       Location:
         com/android/build/gradle/internal/pipeline/VariantInfoImpl.<init>(Lcom/android/build/gradle/internal/scope/VariantScope;)V
@200: goto
       Reason:
         Error exists in the bytecode
       Bytecode:
         0000000: 2b12 3cb8 0034 2a2b b900 4201 0059 1244
         0000010: b800 47b6 004d b900 5201 002b b900 5401
         0000020: 0059 1256 b800 472b b900 4201 0059 1244
         0000030: b800 47b6 005a c000 5c59 125e b800 47b9
         0000040: 0061 0100 5912 63b8 0047 2bb9 0042 0100
         0000050: 5912 44b8 0047 b600 6759 1269 b800 47c0
         0000060: 006b 4d3a 0e3a 0d36 0c3a 0b03 3e2c 3a04
         0000070: bb00 6d59 2c10 0ab8 0073 b700 76c0 0078
         0000080: 3a05 0336 0619 04b9 007c 0100 3a07 1907
         0000090: b900 8101 0099 0036 1907 b900 8501 003a
         00000a0: 0819 0519 08c0 0087 3a09 3a0f 0336 0a19
         00000b0: 0959 1289 b800 47b9 008a 0100 3a10 190f
         00000c0: 1910 b900 8e02 0057 a7ff c619 05c0 0090
         00000d0: 3a0f 190b 150c 190d 190e 190f c000 6bb8
         00000e0: 0096 2bb9 0042 0100 5912 44b8 0047 b600
         00000f0: 5ac0 005c 5912 5eb8 0047 b900 9801 00b7
         0000100: 009a b1
       Stackmap Table:
         full_frame(@142,{UninitializedThis,Object[#62],Object[#107],Integer,Object[#107],Object[#120],Integer,Object[#126],Top,Top,Top,UninitializedThis,Integer,Object[#169],Object[#169]},{})
         same_frame(@203)


* 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

error Failed to install the app. Make sure you have the Android development environment set up: https://facebook.github.io/react-native/docs/getting-started.html#android-development-environment. Run CLI with --verbose flag for more details.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':app'.
> Failed to notify project evaluation listener.
   > Uninitialized object exists on backward branch 142
     Exception Details:
       Location:
         com/android/build/gradle/internal/pipeline/VariantInfoImpl.<init>(Lcom/android/build/gradle/internal/scope/VariantScope;)V
@200: goto
       Reason:
         Error exists in the bytecode
       Bytecode:
         0000000: 2b12 3cb8 0034 2a2b b900 4201 0059 1244
         0000010: b800 47b6 004d b900 5201 002b b900 5401
         0000020: 0059 1256 b800 472b b900 4201 0059 1244
         0000030: b800 47b6 005a c000 5c59 125e b800 47b9
         0000040: 0061 0100 5912 63b8 0047 2bb9 0042 0100
         0000050: 5912 44b8 0047 b600 6759 1269 b800 47c0
         0000060: 006b 4d3a 0e3a 0d36 0c3a 0b03 3e2c 3a04
         0000070: bb00 6d59 2c10 0ab8 0073 b700 76c0 0078
         0000080: 3a05 0336 0619 04b9 007c 0100 3a07 1907
         0000090: b900 8101 0099 0036 1907 b900 8501 003a
         00000a0: 0819 0519 08c0 0087 3a09 3a0f 0336 0a19
         00000b0: 0959 1289 b800 47b9 008a 0100 3a10 190f
         00000c0: 1910 b900 8e02 0057 a7ff c619 05c0 0090
         00000d0: 3a0f 190b 150c 190d 190e 190f c000 6bb8
         00000e0: 0096 2bb9 0042 0100 5912 44b8 0047 b600
         00000f0: 5ac0 005c 5912 5eb8 0047 b900 9801 00b7
         0000100: 009a b1
       Stackmap Table:
         full_frame(@142,{UninitializedThis,Object[#62],Object[#107],Integer,Object[#107],Object[#120],Integer,Object[#126],Top,Top,Top,UninitializedThis,Integer,Object[#169],Object[#169]},{})
         same_frame(@203)

我曾尝试重新安装android studio和gradles以及react-native cli等,但是失败并出现相同的错误。
它是在android studio中成功构建的

最佳答案

我知道这很老,但也许可以帮助某人。

只需升级您的JRE / JDK。版本1.8.20与此有关。

取自https://stackoverflow.com/a/57605913

关于android - react 原生无法构建Android APK。 gradlew clean和…命令失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57164000/

相关文章:

android - 如何在android studio中更新Gradle文件

android - 如何配置SonarRunner属性以读取android单元测试和junit测试的junit报告

android - 支持 NFC 的手机充当 NFC 标签

react-native - 有没有办法控制系统音量?

react-native - 如何在 React Native 中更改 textInput 占位符的字体系列

javascript - 将 React 小部件嵌入到另一个网站中

android - Google Play 服务 GCM 10.0.1 要求将 “update” 返回到 9.0.0

Android交叉编译C,无配置文件

android - Jetpack Compose Row 中的等宽元素

android - 如何在kotlin中使用协程每隔几毫秒调用一个函数