编译到Android设备时反应本机新构建错误

编译到Android设备时反应本机新构建错误

本文介绍了编译到Android设备时反应本机新构建错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近使用 react-native init 构建了新的应用程序.

I recently build fresh app using react-native init.

运行 react-native run-android 后,我收到此错误:

After run react-native run-android I got this error:

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 但仍然没有运气.

I've already tried to run gradlew clean inside my android folder but still no luck.

有什么解决办法吗?

推荐答案

遇到了同样的问题,经过大量故障排除后我发现 android 项目已损坏.这是我修复我的方法:

Had the same issue, and after a lot of troubleshooting I found out that the android project was corrupted. Here's how I fixed mine:

来自项目文件夹:

  1. rm -rf android
  2. react-native 升级

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

Note: just running react-native upgrade without deleting the android folder does not seem to work.

这篇关于编译到Android设备时反应本机新构建错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-24 11:53