Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android build crashing because of "Task :react-native-svg:compileDebugJavaWithJavac FAILED" #1723

Closed
prathusingh opened this issue Mar 19, 2022 · 13 comments

Comments

@prathusingh
Copy link

prathusingh commented Mar 19, 2022

Bug

Android build crashing because of "Task :react-native-svg:compileDebugJavaWithJavac FAILED"
Stack trace

info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 1278 file(s) to forward-jetify. Using 4 workers...
info JS server already running.
info Installing the app...
> Task :react-native-svg:compileDebugJavaWithJavac FAILED

Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.

You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

See https://docs.gradle.org/7.2/userguide/command_line_interface.html#sec:command_line_warnings
27 actionable tasks: 2 executed, 25 up-to-date

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':react-native-svg:compileDebugJavaWithJavac'.
> 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 19s

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-svg:compileDebugJavaWithJavac'.
> 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 19s

    at makeError (/Users/prathu/Projects/passion/mint/MintMobile/node_modules/execa/index.js:174:9)
    at /Users/prathu/Projects/passion/mint/MintMobile/node_modules/execa/index.js:278:16
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
    at async runOnAllDevices (/Users/prathu/Projects/passion/mint/MintMobile/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.js:109:5)
    at async Command.handleAction (/Users/prathu/Projects/passion/mint/MintMobile/node_modules/@react-native-community/cli/build/index.js:192:9)
info Run CLI with --verbose flag for more details.

Environment info

"react-native": "0.67.3",
"react-native-svg": "^12.3.0"
@CorentinHeroux
Copy link

Same mistake, did you find a solution?

@ShubhamBathe-KM
Copy link

Facing same issue any updates regarding the solution?

@gusilveiramp
Copy link

Same here...
Trying to find a solution...

@shendypratamaa
Copy link

same here

@ShubhamBathe-KM
Copy link

I upgraded my Project's react native version as follows:-

"react-native": "^0.62.2"  ==> "react-native": "^0.64.2"
"react-native-svg": "^12.1.0" ==> "react-native-svg": "12.1.1"

It working for me now. No more app crashes after installation.

@unicornRainbows
Copy link

Is this still an issue? I feel like I may be having it with.

"react-native-svg": "^13.0.0",
"react-native": "0.69.4"

Being brave

@hit-cod
Copy link

hit-cod commented Sep 6, 2022

ye, it is an issue, having the same on "react-native-svg": "^13.1.0". any progress?

@SunshineH2
Copy link

same here....any solution?

@kristianmarkuy
Copy link

have found any solution on this?

@WoLewicki
Copy link
Member

I copied the error's message and found this thread: https://stackoverflow.com/questions/64968851/could-not-find-tools-jar-please-check-that-library-internet-plug-ins-javaapple. It looks like not an issue connected to the library itself, but rather a problem with configuration. I'll close this issue then. Feel free to comment here if something is wrong and we can always reopen it then. Also, it would be best to have a simple reproduction of the issue if it still exists.

@bn-serhiimalyshko
Copy link

The article above helped me to fix this issue, because a forgot to update my JAVA_HOME variable in my ~/.zprofile
You just need to add in your ~/.zprofile (or ~/.zshrc or ~/.bash_profile or ~/.bash_rc) the following line:
export JAVA_HOME=/Library/Java/JavaVirtualMachines/zulu-17.jdk/Contents/Home
It also is described in react native documentation.

My react-native version is 0.73.4, and react-native-svg version is 14.1.0. Hope it can be helpful for someone else :)

@FranciscoKloganB
Copy link

FranciscoKloganB commented May 5, 2024

The article above helped me to fix this issue, because a forgot to update my JAVA_HOME variable in my ~/.zprofile You just need to add in your ~/.zprofile (or ~/.zshrc or ~/.bash_profile or ~/.bash_rc) the following line: export JAVA_HOME=/Library/Java/JavaVirtualMachines/zulu-17.jdk/Contents/Home It also is described in react native documentation.

My react-native version is 0.73.4, and react-native-svg version is 14.1.0. Hope it can be helpful for someone else :)

Unfortunatly, this was not enough for me. Since I use the asdf package manager, I took the change to double check that my JAVA_HOME was exported correctly. I used java openjdk-21 mostly to run Android Studio for an old Ionic project. I am trying out nx/expo/react-native/detox generators for the first time and I ran into this issue when trying to run tests. I saw a random GitHub issue somewhere that suggested react-native or react-native-svg does not support just about any JDK, so I downgraded to java openjdk-20.0.2 and I was able to get past this error. Now my monorepo tests are failing on "jest" land, which is something I am more comfortable debugging. :)

@akansha1907
Copy link

After exploring numerous solutions, I finally resolved the error by running the command: npm install react-native-svg@latest
my react native version: 0.76.1
react-native-sgv version: ^15.9.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests