简体   繁体   中英

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

Hello I am new to React Native. I am trying to use an Android Emulator to run my Android App with React Native in Windows OS. I followed the instructions here https://reactnative.dev/docs/environment-setup but I am getting these errors:

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

This is my gradle properties:

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

My Java JDK version is 15.0.2

I tried changing the gradle properties to an earlier version but it doesn't let me since the minimum is 6.5version.

Can anybody help me please?

cmd:

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

if not sucess try start as npx react-native start --reset-cache

if using expo: expo start r -c

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM