Java 在编译到android设备时反应本机新生成错误

Java 在编译到android设备时反应本机新生成错误,java,android,react-native,Java,Android,React Native,我最近使用react native init构建了一个全新的应用程序 运行react native run android后,我遇到了以下错误: FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':app:preDexDebug'. > com.android.ide.common.process.ProcessException: org.gradle.proce

我最近使用
react native init
构建了一个全新的应用程序

运行
react native run android
后,我遇到了以下错误:

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:preDexDebug'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.8.0_112\bin\java.exe'' finished with non-zero exit value 1

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 19.52 secs
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/android-setup.html

(node:3632) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): TypeError: Cannot read property 'message' of undefined
(node:3632) DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
我已经尝试在我的android文件夹中运行
gradlew clean
,但仍然没有成功


有解决方案吗?

也有同样的问题,经过大量的故障排除,我发现android项目已经损坏。下面是我如何修复我的:

从项目文件夹:

  • rm-rf安卓系统
  • react本机升级

  • 注意:只运行react native upgrade而不删除android文件夹似乎不起作用。

    也有同样的问题,经过大量的故障排除,我发现android项目已损坏。下面是我如何修复我的:

    从项目文件夹:

  • rm-rf安卓系统
  • react本机升级
  • 注意:只运行react native upgrade而不删除android文件夹似乎不起作用。

    看看这个,看看这个,然后