I know that this question is popular, but no one of solutions can help me. I used this, this, this and this solutions, but no one help me.
I want to implement uiautomator Tests and need to build my build.xml with ant, but get this strange error.
I use Windows 8.1
My JAVA_HOME system variable set to c:\programs files\java\jdk1.7.0_51 and to c:\programs files(x86)\java\jdk1.7.0_51
My PATH system variable set also to %JAVA_HOME%/bin, my %ANT_HOME% is set to c:\apache-ant.
But when I execute ant build in the android app derictory I get the
unable to locate tools.jar. Expected find it in C:\Program Files\Java\jre7\lib\tools.jar BUILD FAILED Perhaps JAVA_HOME does not point to the JDK
But my JAVA_HOME points to right JDK ! I confused with this. I also rebuild my build several times, I've got the same.
Will be glad if somebody help me.
Ant expects the tools. jar file to be in the %JAVA_HOME%/lib but tools. jar is distributed with the JDK.
The problem is with version of JDK you are using. The Intellij version 2020.2 supports only upto JDK 14. So either you have to lower the JDK version to 14 or update the IntelliJ to a newer version like 2021.
The jar tool combines multiple files into a single JAR archive file. jar is a general-purpose archiving and compression tool, based on ZIP and the ZLIB compression format. However, jar was designed mainly to facilitate the packaging of java applets or applications into a single archive.
I too had this problem and solved it by setting variables like this :
[1] ANT_HOME - C:\apache-ant-1.9.3 [2] JAVA_HOME - C:\Program Files\Java\jdk1.7.0_21 [3] PATH - D:\Android_Development\android_sdk\platform-tools\;%ANT_HOME%\bin;%JAVA_HOME%\bin;D:\Android_Development\android_sdk\tools
Note : Set all these in System variables not in user variables.
This solved my problem.
Hope it helps.
To Recover this problems you can just copy the tools.jar from "C:\ProgramFiles\Java\jdk1.7.0\lib" directly into "C:\Program Files\Java\jre7\lib\".You will successfully recover the problems.
It works!..
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