New to Android Studio + Gradle.
I'm trying to run my app from the command line using:
gradlew installDebug
The app gets installed on my device only when I execute that command when Studio just got opened and do that initial syncing/building thing.
Whenever I modified my code, and try to run that command again, the build fails and shows this error:
Execution failed for task ':app:compileDebugJavaWithJavac'
> Could not find tools.jar
How do I solve this problem? Thanks in advance.
Setting the JAVA_HOME variable to C:\Program Files\Java\jdkX.XX worked for me.
It was previously set to the JRE directory for some reason.
Are you on Linux? What does echo $JAVA_HOME
outputs?
I had a similar issue when running react-native run-android
. After setting $JAVA_HOME (which hadn't existed) to a JDK folder, the problem was solved. In my case, I added the following line to the end of .bashrc file:
export JAVA_HOME="path/to/a/folder/with/JDK/jdk1.8.0_60"
and restarted the terminal.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With