I was working with react native in my windows 10 for months. after upgrading to windows 11 and installing previous tools , I am not able to run my react native project . I installed android studio , SDK, JDK, node and other tools like before. but I got this error after running npx react-native run-android command:
FAILURE: Build failed with an exception.
Where:
Build file 'C:\Users\Username\Documents\React Native Projects\myapp\android\app\build.gradle' line: 1
What went wrong:
A problem occurred evaluating project ':app'.
Failed to apply plugin 'com.android.internal.application'.
Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8.
You can try some of the following options:
- changing the IDE settings.
- changing the JAVA_HOME environment variable.
- changing org.gradle.java.home in gradle.properties.
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 38s
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
Note: C:\Users\Username\Documents\React Native Projects\myapp\node_modules\react-native-gradle-plugin\src\main\java\com\facebook\react\codegen\generator\SchemaJsonParser.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
FAILURE: Build failed with an exception.
Where:
Build file 'C:\Users\Username\Documents\React Native Projects\myapp\android\app\build.gradle' line: 1
What went wrong:
A problem occurred evaluating project ':app'.
Failed to apply plugin 'com.android.internal.application'.
Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8.
You can try some of the following options:
- changing the IDE settings.
- changing the JAVA_HOME environment variable.
- changing org.gradle.java.home in gradle.properties.
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 38s
at makeError (C:\Users\Username\Documents\React Native Projects\myapp\node_modules\#react-native-community\cli-platform-android\node_modules\execa\index.js:174:9)
at C:\Users\Username\Documents\React Native Projects\myapp\node_modules\#react-native-community\cli-platform-android\node_modules\execa\index.js:278:16
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async runOnAllDevices (C:\Users\Username\Documents\React Native Projects\myapp\node_modules\#react-native-community\cli-platform-android\build\commands\runAndroid\runOnAllDevices.js:109:5)
at async Command.handleAction (C:\Users\Username\Documents\React Native Projects\myapp\node_modules\#react-native-community\cli\build\index.js:192:9)
info Run CLI with --verbose flag for more details.
This question was asked many times before, but I did not get an answer from them . I tried gradlew clean but I get same error (Build Failed). for some developers chmod +x gradlew worked. but it is for Linux and Mac. I am using windows . is there any replacement command for windows or other way to fix this problem ?
thanks .
Open Android Studio Settings and follow this path. Open the dropdown for Gradle JDK and select 11 from the dropdown.
Related
Hi i'm trying to use the camera with react-native-camera in react native but when i run the app it shows this error
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 1165 file(s) to forward-jetify. Using 8 workers...
info JS server already running.
info Launching emulator...
error Failed to launch emulator. Reason: Emulator exited before boot..
warn Please launch an emulator manually or connect a device. Otherwise app may fail to launch.
info Installing the app...
> Task :react-native-camera:compileMlkitDebugJavaWithJavac FAILED
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.9/userguide/command_line_interface.html#sec:command_line_warnings
98 actionable tasks: 2 executed, 96 up-to-date
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':react-native-camera:compileMlkitDebugJavaWithJavac'.
> Could not find tools.jar. Please check that /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home contains a valid JDK installation.
* 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 10s
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 app:installDebug -PreactNativeDevServerPort=8081
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':react-native-camera:compileMlkitDebugJavaWithJavac'.
> Could not find tools.jar. Please check that /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home contains a valid JDK installation.
* 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 10s
at makeError (/Users/calebgarcia/Dev/Tibeo/node_modules/#react-native-community/cli-platform-android/node_modules/execa/index.js:174:9)
at /Users/calebgarcia/Dev/Tibeo/node_modules/#react-native-community/cli-platform-android/node_modules/execa/index.js:278:16
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async runOnAllDevices (/Users/calebgarcia/Dev/Tibeo/node_modules/#react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.js:109:5)
at async Command.handleAction (/Users/calebgarcia/Dev/Tibeo/node_modules/#react-native-community/cli/build/index.js:192:9)
info Run CLI with --verbose flag for more details.
I've had a lot of problems when trying to run the react native apps on android but in ios they run perfectly.
Do you guys have any idea how can i solve the error.
Thanks
firstly check whether what jdk version you have installed (got to terminal and check by java --version)
make sure u have added that jre path to your environment variables
if these condition already u have done then follow below link
[https://dev.to/larrydanny/could-not-find-tools-jar-4363][1]
your proble will be solved....
I am building a flutter project using Gradle. When I ran
flutter build appbundle
I got the error as shown below
FAILURE: Build failed with an exception.
* What went wrong: Execution failed for task ':image_gallery_saver:compileReleaseKotlin'.
> Kotlin could not find the required JDK tools in the Java installation '/Library/Internet
Plug-Ins/JavaAppletPlugin.plugin/Contents/Home' used by Gradle. Make
sure Gradle is running on a JDK, not JRE.
* 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 24s
Running Gradle task 'bundleRelease'...
Running Gradle task 'bundleRelease'... Done
25.7s Gradle task bundleRelease failed with exit code 1
Please help me regarding this issue.
Thanks in advance!
Make sure Gradle is running on a JDK, not JRE
You are running gradle on a JRE instead of a JDK, install JDK 16 or below (17 is not supported yet), append its bin directory to the PATH variable and remove the one of the JRE.
MacBook-Air mlaapp % npx react-native run-android
warn The following packages use deprecated "rnpm" config that will stop working from next release:
- react-native-video: https://github.com/react-native-community/react-native-video#readme
Please notify their maintainers about it. You can find more details at https://github.com/react-native-community/cli/blob/master/docs/configuration.md#migration-guide.
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 1232 file(s) to forward-jetify. Using 4 workers...
info Starting JS server...
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 1s
error Failed to install the app. Make sure you have the Android development environment set up: https://facebook.github.io/react-native/docs/getting-started.html#android-development-environment. Run CLI with --verbose flag for more details.
Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081
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 1s
at checkExecSyncError (child_process.js:631:11)
at execFileSync (child_process.js:649:15)
at runOnAllDevices (/Users/varmabiraju/projects/Joshi/MyProjects/mlaapp/node_modules/#react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.js:94:39)
at buildAndRun (/Users/varmabiraju/projects/Joshi/MyProjects/mlaapp/node_modules/#react-native-community/cli-platform-android/build/commands/runAndroid/index.js:179:41)
at /Users/varmabiraju/projects/Joshi/MyProjects/mlaapp/node_modules/#react-native-community/cli-platform-android/build/commands/runAndroid/index.js:133:12
at processTicksAndRejections (internal/process/task_queues.js:88:5)
at async Command.handleAction (/Users/varmabraju/projects/Joshi/MyProjects/mlaapp/node_modules/react-native/node_modules/#react-native-community/cli/build/index.js:182:9)
Try changing sdk versions in /android/build.gradle
compileSdkVersion = 30
targetSdkVersion = 30
from the comments, it seems that you are not using the gradle version 6.3. can you update your android build to use gradle 6.3 and see if the issue still persists?
another user faced a similar issue and reported this on github. you may want to take a closer look at it here.
This worked for me: Open task manager (of your OS) and kill adb.exe process. Now start adb again, now adb should start normally.
If this is your error
error for nativeDevServerPort
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 6.2 all zip causing this error for run-android please change or upgrade the distributionUrl version of gradle in
gradle-wrapper.properties to
distributionUrl=https://services.gradle.org/distributions/gradle-6.3-all.zip
Hope this could help you in installing your react-native application in android
I'm trying to build an Ionic Android app but no matter what i do i get this error, here is the full error
===========================================================================
Checking Java JDK and Android SDK versions
ANDROID_SDK_ROOT=C:\Program Files\Java\jdk1.8.0_251 (recommended setting)
ANDROID_HOME=C:\Program Files\Java\jdk1.8.0_251 (DEPRECATED)
Subproject Path: CordovaLib
Subproject Path: app
Configure project :appProject evaluation failed including an error in afterEvaluate {}. Run with --stacktrace for details of the afterEvaluate {} error.
FAILURE: Build failed with an exception.
Where:
Script 'C:\Users\Peter Snee\Documents\AngularIonic\quotesApp\platforms\android\CordovaLib\cordova.gradle' line: 68
What went wrong:
A problem occurred evaluating project ':app'.
No installed build tools found. Install the Android build tools version 19.1.0 or higher.
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 4s
C:\Users\Peter Snee\Documents\AngularIonic\quotesApp\platforms\android\gradlew: Command failed with exit code 1 Error output:
Project evaluation failed including an error in afterEvaluate {}. Run with --stacktrace for details of the afterEvaluate {} error.
FAILURE: Build failed with an exception.
Where:
Script 'C:\Users\Peter Snee\Documents\AngularIonic\quotesApp\platforms\android\CordovaLib\cordova.gradle' line: 68
What went wrong:
A problem occurred evaluating project ':app'.
No installed build tools found. Install the Android build tools version 19.1.0 or higher.
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 4s
[ERROR] An error occurred while running subprocess cordova.
cordova.cmd build android exited with exit code 1.
Re-running this command with the --verbose flag may provide more information.
===========================================================================
I have uninstalled Android studio, i have changed a few environment variables, nothing seems to be working for me so im probably missing something,
Any help is greatly appreciated !
thanks
Got it,
It turns out my paths were wrong in the environment variables,
I ran
android list sdk
in the cmd and got the exact paths,
rookie mistake but sure look.
I have installed the latest build-tools; 29.0.2. Still it says no build-tools installed
C:\Users\user\Downloads\android-studio-ide-\android-studio\bin\runnerw.exe C:\Users\user\AppData\Roaming\npm\cordova.cmd run android
Checking Java JDK and Android SDK versions
ANDROID_SDK_ROOT=undefined (recommended setting)
ANDROID_HOME=C:\Users\user\AppData\Local\Android\Sdk (DEPRECATED)
Subproject Path: CordovaLib
Subproject Path: app
Project evaluation failed including an error in afterEvaluate {}. Run with --stacktrace for details of the afterEvaluate {} error.
FAILURE: Build failed with an exception.
Where:
Script 'C:\Users\user\LagBus\platforms\android\CordovaLib\cordova.gradle' line: 68
What went wrong:
Configure project :app
A problem occurred evaluating project ':app'.
No installed build tools found. Install the Android build tools version 19.1.0 or higher.
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 16s
C:\Users\user\LagBus\platforms\android\gradlew: Command failed with exit code 1 Error output:
Project evaluation failed including an error in afterEvaluate {}. Run with --stacktrace for details of the afterEvaluate {} error.
FAILURE: Build failed with an exception.
Where:
Script 'C:\Users\user\LagBus\platforms\android\CordovaLib\cordova.gradle' line: 68
What went wrong:
A problem occurred evaluating project ':app'.
No installed build tools found. Install the Android build tools version 19.1.0 or higher.
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 16s
Picked up _JAVA_OPTIONS: -Xmx1024M
It might be that you don't have the android tools configured in your PATH, so cordova can't find them.
So, check that, in your path you have access to the android build tools and even other Android development environment configurations.
This is an example of a problem similar to yours, and how to solve it:
According to this: https://github.com/ionic-team/ionic/issues/13120
EDIT: you have your answer here