簡體   English   中英

React Native 和 Android Studio:應用構建失敗。 錯誤:命令失敗:gradlew.bat app:installDebug -PreactNativeDevServerPort=8081

[英]React Native and Android Studio: App Failed to build. Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081

你好,我是 React Native 的新手。 我正在嘗試使用 Android 模擬器在 Windows 操作系統中使用 React Native 運行我的 Android 應用程序。 我按照https://reactnative.dev/docs/environment-setup此處的說明進行操作,但出現以下錯誤:

info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 967 file(s) to forward-jetify. Using 8 workers...
info JS server already running.
* daemon not running; starting now at tcp:5037
* daemon started successfully
info Launching emulator...
info Successfully launched emulator.
info Installing the app...

FAILURE: Build failed with an exception.

* What went wrong:
Could not initialize class org.codehaus.groovy.runtime.InvokerHelper

* 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 2s

error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup. Run CLI with --verbose flag for more details.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081

這是我的 gradle 屬性:

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https://services.gradle.org/distributions/gradle-6.5-all.zip

我的Java JDK版本是15.0.2

我嘗試將 gradle 屬性更改為較早的版本,但由於最低版本為 6.5 版本,因此我沒有這樣做。

有人可以幫我嗎?

cmd:

cd ProjectFolder && cd android &&./gradlew clean

如果不成功,請嘗試以 npx react-native start --reset-cache 開頭

如果使用 expo: expo 開始 r -c

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM