4

So, I've been trying to build a project in LibGDX for about 10 hours now. In case you'r unfamiliar, LibGDX is one of those platforms where you specify a project directory at the start, along with any required SDKs and then when you're ready to start coding it will generate a project for you.

Anyway, I've been having a problem where every time I try to build it fails with the single error message:

Execution failed for task :core:compileJava.

Could not find tools.jar

I'm guessing "tools.jar" is a package within the Android SDK, as this is the only repository needed to build, it doesn't ask for a JRE or even the Java SDK. just the Android SDK.

I have been looking in the SDK manager, I have installed all of the packages labelled "Android-SDK Tools", "Android-SDK Platform Tools" and "Android SDK Build Tools" but there is nothing else that includes "tools.jar", I am looking for some light shed on this topic as it is a very grey area. I would like to know where this .jar file comes from and what exactly it includes. Can it be installed from the Android SDK?

There have been similar questions like this before which only fit narrow situations, If someone could provide a holistic description of the tools.jar package it would benefit a great deal for me and everyone else that needs it in their 3rd-party android IDEs.

For the record, it's building with Gradle and my current SDK is well-equipped enough to build full-fledged apps in Android Studio.

Please don't answer this question with a question unless I have left out some information that is dire to finding an adequate solution

Jalapeno
  • 202
  • 1
  • 2
  • 9
  • copy tool.jar from jdk/lib to android studio/lib and see if it works. – Vishwajit Palankar Jul 02 '15 at 10:36
  • 1
    YOU ARE A GENIUS!!! thank you so much I would have never thought to look in the JDK folder because neither android studio nor LibGDX has any mention of it. For anyone with the same problem: download the latest JDK from oracle and look in the folder "lib" – Jalapeno Jul 02 '15 at 10:55

5 Answers5

8

Try copying tools.jar from %JAVA_HOME\lib to Android Studio\lib

Vishwajit Palankar
  • 3,033
  • 3
  • 28
  • 48
  • 3
    YES! or in my case, it was from 'C:\Program Files\Java\jdk1.8.0_45\lib' to 'Documents\android-sdk-windows' but your premise is spot-on – Jalapeno Jul 02 '15 at 11:18
2

For me, copying tools.jar to Android lib folder alone didn't solve my problem.

But I also had to create a System Variable 'JAVA_HOME' in Windows Environment Variables with path to the latest JDK folder.

Restarted Android Studio, and this solved by problem.

Rony Samuel
  • 301
  • 3
  • 3
1

My Android Studio Version: 4.2.1

The "tools.jar" is provided by Oracle JDK which is required by android studio for compilation - I have faced this issue after updating android studio to latest version in my PC.

To Resolve the issue follow below steps:

  1. In Android studio File -> Project Structure -> SDKs (Under Platform Settings)

    A) Add JDK path by pressing '+' symbol in middle pane if suppose JDK/JDK home path is not present in the middle pane already (Middle pane also contains the Downloaded Android SDK's)

    B) Java sdk will be usually present/installed in the path 64 bit => "C:\Program Files\Java\jdk1.X.Y_ABC" (In my PC it is 1.8.0_202) or 32 bit => "C:\Program Files (x86)\Java\jdk1.X.Y_ABC"

  2. If suppose you don't have JDK installed in your PC, please download and install from Oracle Java website https://www.oracle.com/java/technologies/javase/javase-jdk8-downloads.html

  3. Set JDK and JRE Path(Download both from webpage mentioned in step 2) in system environment variable

    A) Press windows key type "Edit the system environment variables" and open the application

    B) Go to Advanced -> Environment Variables Under system variables add JAVA_HOME and JRE_HOME as below

    Set Windows system environment variable

  1. Add jdk lib path on the Path environment variable under user variables (this step is required only if the error not resolves with the previous steps) C:\Program Files\Java\jdk1.X.Y_ABC\lib
Ganesh Ram
  • 11
  • 1
0

In my case, I have five jdk and some have tools.jar and other not, my solution is copy paste this tools.jar in all lib of jdk.

Leave
  • 1
  • 1
    I'm pretty sure this could introcude version problems in certain cirumstances, because you lose the overview, which version of tools.jar you copied to where – Markus Weninger Mar 04 '16 at 23:01
0

Nothing worked for me. So I Copied tools.jar and pasted it in C:\Users\UMAR_\AppData\Local\Android\Sdk\platforms\android-30 which is the path to the library for the Android API 30 Platform. I pasted tools.jar in every folder and it start working.

I didn't have tools.jar initially but followed this link and downloaded https://www.oracle.com/java/technologies/javase/javase-jdk8-downloads.html

Also added to a environment variable.. but what worked was in the first para, I still don't know if adding to variable was necessary or not.

mobdev991
  • 43
  • 1
  • 5