To solve Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081 error follow below methods.
ERROR LOG
error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:checkDebugAarMetadata'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction
Contents
How to solve Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081 ?
To correct the error The app could not be installed. Ascertain that you have the Android development environment installed. Simply modify the compileSdkVersion variable in your build.gradle file. Open the build.gradle file in Android. Change the value of compileSdkVersion from 29 to 30. Set targetSdkVersion to 30 instead of 29. Now run once more.
- Open
android > build.gradle
file. - Change
compileSdkVersion
from 29 to 30. - Change
targetSdkVersion
from 29 to 30. - Now try to run again.
Solve Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081 by Adding ResolutionStrategy
To overcome this issue, add ResolutionStrategy to your build.gradle file. Here’s an example: Include the following line in the build.gradle file:
configurations.all {
resolutionStrategy { force 'androidx.core:core-ktx:1.6.0 }
}
Fix Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081 by Adding 1.7.0-alpha01
To overcome this issue, add the below code to your build.gradle file. Here’s an example: Include the following line in the build.gradle file:
configurations.all {
resolutionStrategy {
force 'androidx.core:core-ktx:1.6.0'
}
}
and then apply,
implementation 'androidx.core:core-ktx:1.7.0-alpha01'
Fix Command failed: gradlew.bat in Windows Machine
If you have WINDOWS machine, please follow these steps:
Optional (
Delete iOS, Android folders
Run `react-native eject` ( that command will rebuild deleted folders for you )
)
Then :
cd ./android
./gradlew.bat installDebug
( with dot at the beggining )
Once it’s successfully finished then go to step 3cd ../
( go back to root folder )react-native run-android
Hope the above solution works.
Also read :
TypeError: __array__() takes 1 positional argument but 2 were given
Module parse failed: Unexpected token (763:13) in VueJs