I've been trying to generate an Eclipse project using libGDX, in order to use it with this tutorial. However, everytime I generate the project I get the error message:
Execution failed for task ':core:compileJava'.
Could not find tools.jar
The images below show the settings I use and the messages I get.
I'm using the most recent version of Eclipse and the Android SDK. I got the Android version of Eclipse through the installation program from the Eclipse website and I got the Android SDK through Eclipse. Everything is installed in the default folders. I've got the most recent versions of both the 32 and 64 bits versions of Java.
Could anyone tell me what I'm doing wrong?
PS. My question might be similar to this question: What exactly is “tools.jar” in the Android SDK?. However, the answer to that question only applies to Android studio users.
Check your installed JDK.
You have to set the system property "java.home" and the environment variable JAVA_HOME to a valid JDK.
Check gradle.properties file at the root of your project with the following property:
org.gradle.java.home=C:\\Program Files\\Java\\jdk1.8.0_74
org.gradle.java.home needs to point to a valid JDK location.
Without this file, you get the same error (Could not find tools.jar). With the file present, this is no longer an issue.
Just add this line to gradle.properties:
org.gradle.java.home=C:\\Program Files\\Java\\jdk1.8.0_131
Related
Android Studio is using the following JDK location when running Gradle:
E:\Android\Android Studio\jre
Using different JDK locations on different processes might cause Gradle to
spawn multiple daemons, for example, by executing Gradle tasks from a terminal
while using Android Studio.
More info...
Select a JDK from the File System
Do not show this warning again
The above is the warning that I am getting, Should I specify the the directory where the Java JDK is installed manually in the Android studio?
What does this problem imply to?
I have personally never had problems with this error. However, you might have to choose the directory if in case you copy the project to a new system. It's better to install JDK from the official repo and give the system path in the settings.
Ever since installing Android Studio 3.2, I haven't been able to run Java, I have tried jdk-8u181-windows-x64, jdk-10.0.2_windows-x64_bin, jdk-11_windows-x64_bin, setting PATH and reinstalling everything umpteen times, the result is the same - no "java" appears and the error message is: -
Gradle sync failed: Could not run JVM from the selected JDK.
Please ensure JDK installation is valid and compatible with the current OS (Windows 8.1 6.3, amd64).
If you are using embedded JDK, please make sure to download Android Studio bundle compatible
with the current OS. For example, for x86 systems please choose a 32 bits download option. (369 ms)
Notes: I used to be able to open the java folder but after playing with it too much, something went wrong, so, I decided to start afresh... and I am dead ever since.
Is Studio 3.2 flawed? Not compatible with Java at all? Or am I missing something? is there a older Android Studio I can test? Thanks for any help you may provide.
In my case, the following solved it:
File->Other settings->Default Project Structure...
In "JDK Location", I previously had the oracle jdk selected. To fix this issue, I instead checked "Use embedded JDK (recommended)"
Solved YES
Other Settings ---> Default Project Structure ---> Uncheck Embedded jdk ( Write Your Own jdk Location )
In my case, the following solved it:
File->Other settings->Default Project Structure...
setting the JAVA_HOME environment variable to C:\Program Files\Java\jdk1.8.0_181
my JDK Source File
Try setting your SDK location. I had the same problem with Android Studio 3.2 (but I also switched to openjdk, so that could be the source of my problem). Anyway, after pointing SDK location to the root of my JDK it worked like a charm.
To change SDK location click on the Android project Window and then press F4. In the new Window choose SDK location and set it to point to the root of your JDK.
i got mine working by setting the JAVA_HOME environment variable to C:\Program Files\Java\jdk1.8.0_181\bin my jdk folder
I have a JavaFX app that I build with Gradle and Java 8. I recently got a new laptop and installed Java 10 JDK instead of Java 8 and didn't think it'd be a big deal. However, when I try to import the Gradle project into Intellij I get this error:
org.gradle.api.ProjectConfigurationException: A problem occurred configuring root project 'MyProject'
Caused by: org.gradle.api.GradleException: Couldn't find Ant-JavaFX-library, please make sure you've installed some JDK which includes JavaFX (e.g. OracleJDK or OpenJDK and OpenJFX), and JAVA_HOME is set properly.
at de.dynamicfiles.projects.gradle.plugins.javafx.JavaFXGradlePlugin.addJavaFXAntJARToGradleBuildpath(JavaFXGradlePlugin.java:112)
More....
I have set JAVA_HOME in the Windows env vars to this path:
C:\Program Files\Java\jdk-10.0.1
How can I solve this problem?
Thanks!
Thanks for the comment feedback on this post I was able to find the problem. I first verified that the JDK 10 installation did drop off ant-javafx.jar into the lib/ dir in JAVA_HOME. It did..!
So it must be Gradle or Intellij.. right? Well there's only one super easy way to build a JavaFX gradle project at the moment and that's with javafx-gradle-plugin. Looking up the repo I can see the last release was a year ago! RED FLAG! Looking through the code I found a pathing check for a now defunct relative path that drops the verbatim error above.
So I submitted a Pull Request to the developer of the project and hopefully that resolves the issue..
That's here: https://github.com/FibreFoX/javafx-gradle-plugin/pull/128 .
In the meantime, I solved locally by copying ant-javafx.jar from it's real path at C:\Program Files\Java\jdk-10.0.1\lib\ant-javafx.jar out into C:\Program Files\Java\lib\ant-javafx.jar. Then I rebuilt the Gradle project and everything worked accordingly, confirming the solution in the PR above.
If you're building JavaFX apps with Gradle right now, you're likely to encounter this issue until the developer fixes it. He claims he's working on a brand-new plugin right now but the last release of this widely used plugin was over a year ago.
Thanks!
I just updated to Android Studio 2.2.1 for Mac. Then I updated the JDK to version 8. Tried to start a new project and run it. I got the following error:
Error:(1, 1) A problem occurred evaluating project ':app'.
java.lang.UnsupportedClassVersionError: com/android/build/gradle/AppPlugin : Unsupported major.minor version 52.0
I also tried going back to JDK version 7 as it says on google site that JDK 8 is unstable for Mac. still got the same error.
Check your android build tools dependencies. In your build.gradle if its something like:
classpath "com.android.tools.build:gradle:+"
It has likely downloaded the alpha of 2.2 and that can cause the error you are seeing.
Try
classpath "com.android.tools.build:gradle:2.1.0"
If you are already using the right build tools version but keep getting this error, maybe one of the third party Android libraries you are using is causing the problem due to the same reason. You can force the dependency version to be used (including transitive) by changing
classpath "com.android.tools.build:gradle:2.1.0"
to
classpath('com.android.tools.build:gradle:2.1.0') {
force = true
}
Documentation: gist and official gradle docs.
I was also facing same problem. I upgraded Android Studio and as it forced to But we need to configure same in App Settings as well.
You can try to update JAVA_HOME to point to JDK 8 location.
In my case, I've updated Android studio project's SDK settings, changed java version in my PATH env variable, but still this error occured. Only updating JAVA_HOME helped me.
I was also facing the same problem. I upgraded Android Studio and as it forced to install JDK 8, downloaded and installed this as well. But we need to configure same in App Settings as well.
Select Project [Right click on the app module] -> Open Module Settings -> Select SDK Location from Left Menu - > Configured correct JDK Version i.e removed the old version and updated path of JDK. Save.
Sync Project.
Problem solved!
EDIT: Elaborated Project word.
If you are on Jenkins, check Java version in Jenkins->Manage Jenkins->Global Tool Configuration->JDK
I had to update mine to JDK 8.
I had same error in 2.3 beta 1 ,
Fixed as follow :
Download latest java jdk
http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
In Android Studio , go to File > Project Structure > SDK Location > select JDK Location path to point to the new jdk installed (Ex: C:\Program Files\Java\jdk1.8.0_111 )
Done !
Ufff, I changed like everything I was able to find to jdk 8 and still no result but then I found Gradle settings in Intellij (preferences > gradle > GradleJVM) and it was ofc wrong, changed that and woala.
I meet the problem too, but I have changed nothing before it's happening. I think google is purposely. Google is trying to use openJDK instead of JDK because of the lawsuit between google and oracle. So, in the new version 2.2.0 of android, we found that there are some new files in the installed folder:
android studio 2.1 files
android studio 2.2 files
Then, I think we have two method to fix it:
Change the JDK environment variable of your OS.
Just click menu File --> Project Structure, choose Use embedded JDK (recommended). I chose this way and it work.
Good luck...
I had a same problem what is work for me is that .
Go
*File>Settings>(on the panel left)Build,Execution,Deployment . then click on Gradle
There is option to Update Gradle. Click on that it will time 3 to 4min and after that error gone.
The simplest way is to update Android Studio to v2.2.3, it includes a fix of JDK8:
Bug fix for a JDK8/Kotlin compiler + dx issue (issue 227729)
It's solved my problem.
I have set the CLASSPATH and HOME_PATH for my JDK in the windows environment variables, do I need to set anything similar for Eclipse in order to compile Android programmes?
The problem I'm having is that Eclipse can be opened and create a program as simple as the Helloworld example, seems to be not an exact way to compile and then I can pack into any execution file so my little Android phone can install with.
Android requires more than just Java, but also the Android SDK. To get it working with Eclipse, you'll also need the Eclipse Android plugin. So, if you can run the HelloWorld program, Java is working. Follow instructions to get Android working here:
http://developer.android.com/sdk/index.html
Also, there's a couple links under the "ADT Bundle" section to just download a self-contained version of Eclipse bundled with the Android SDK to save you from installing the Eclipse Android plugin and configuring anything. You'll unzip the folder in a convenient directory, then see two folders: the Android SDK and another containing Eclipse. You can just run the Eclipse.exe in the Eclipse folder and your Android environment is good to go.
Do you have the android SDK? If not, get it here. It comes with eclipse IDE with all the required things already set up.