首页 > 解决方案 > 我无法让我的 android 应用在 react-native 上运行

问题描述

我无法运行我的项目。我正在尝试修复 2 个错误,但我一无所获。

我做了这里写的一切:

https://facebook.github.io/react-native/docs/getting-started

C:\WINDOWS\system32>cd BabyMobile

C:\Windows\System32\BabyMobile>react-native run-android
info Starting JS server...
info Building and installing the app on the device (cd android && gradlew.bat app:installDebug)...
Starting a Gradle Daemon, 3 stopped Daemons could not be reused, use --status for details
> Task :app:mergeDebugResources FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:mergeDebugResources'.
> java.util.concurrent.ExecutionException: com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource compilation failed
  C:\Windows\System32\BabyMobile\android\app\build\intermediates\res\merged\debug: error: directory does not exist.


* 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 26s
9 actionable tasks: 1 executed, 8 up-to-date
error 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
error Command failed: gradlew.bat app:installDebug. Run CLI with --verbose flag for more details.

C:\Windows\System32\BabyMobile>adb devices
List of devices attached
* daemon not running; starting now at tcp:5037
* daemon started successfully

你能帮我么?

**修复:更新了 android studio,项目在普通 CMD 中初始化(不是管理员)。第二个问题是,我在运行 react-natice run-android 后打开了模拟器,所以你必须先启动模拟器!

标签: androidreact-native

解决方案


推荐阅读