I am trying to build an apk for Android. when I run the command ionic cordova build android I get the error:
Checking Java JDK and Android SDK versions ANDROID_SDK_ROOT=C:\Users\myUserName\AppData\Local\Android\Sdk (recommended setting) ANDROID_HOME=C:\Users\myUserName\AppData\Local\Android\Sdk (DEPRECATED) Requirements check failed for JDK 1.8.x! Detected version: 17.0.1 Check your ANDROID_SDK_ROOT / JAVA_HOME / PATH environment variables.
App · Command "cordova" failed with exit code: 1 App · Updated Cordova config.xml App · ⚠️ [FAIL] Cordova CLI has failed
It says I need JDK 1.8.x, but it detected But I am pretty sure I have JDK 1.8 installed
my JAVA_HOME environment variable is set to C:\Program Files\Java\jdk-17.0.1
I have no idea why I can't get the app to build. Please help!
You need to change your JAVA_HOME entry and put there path to JDK 1.8 installation.
Using Eclipse on Windows 10, I am trying to build the Minecraft Forge MDK, but Gradle tells me it can only find Java 16. Everything was working fine a week ago.
I don't have Java 16 installed except it's default installed for Eclipse.
My JAVA_HOME path is set to
C:\Program Files\Java\jdk1.8.0_291\bin .
Java 8 is installed and the build path on Eclipse is set to
C:\Program Files (x86)\Java\jre1.8.0_291
Adding an org.gradle.java.home set to the same path as my JAVA_HOME returns an error saying there is no valid java home. I am unsure what to do.
My operating system is Pop!_OS 20.10. I am simply trying to run a flutter project, which I created on IntelliJ, on my android device using IntelliJ IDEA. The build is being completed without any errors but when running the app, it says that my JAVA_HOME variable is set to an invalid directory:
Launching lib/main.dart on Mi A2 in debug mode...
Running Gradle task 'assembleDebug'...
ERROR: JAVA_HOME is set to an invalid directory: /app/extra/idea-IU/jre64
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation.
Exception: Gradle task assembleDebug failed with exit code 1
SDKs installed on my platform settings are openjdk-15.0.2, corretto-1.8 and Android API 30 Platform. I didn't manually altered any environment variables before getting this error. After this, I tried to add JAVA_HOME variable to ~/.bashrc and /etc/environment files to point my JDK installation folder like this:
JAVA_HOME="/usr/lib/jvm/default-java"
and also tried with my current java installation:
JAVA_HOME="/usr/lib/jvm/java-11-openjdk-amd64"
but no luck. I did a lot of research and really don't know what to do at this point.
There are two possibilities
1 - Your flutter sdk is may be some old version. Run flutter upgrade to update your flutter sdk.
2 - You might not have installed JDK or the JDK Path is not set in Environment Variables.
Problem I have a newer JDK installed and I need to change the path to that JDK instead of version 73, however I can't find anywhere on the IDE to do this.
Error:
Severity Code Description Project File Line Suppression State
Error JAVA_HOME is set to an invalid directory: C:\Program Files\Java\jdk1.8.0_73 MinecraftMod2 EXEC 0
The JAVA_HOME environment variable which points to the SDK can be set either for the current user only or for everyone, in the Windows computer settings 'Environment variables' dialog.
See for example
How to set java_home on Windows 7?
I installed Android Studio but it was giving me error that I need to install JDK but JDK was already installed. Then I realized it is asking to install 64bit version of JDK.
Anyway I just downloaded latest JDK 64bit version and set the following in Environment Variable but still Android Studio is giving error:
Error
'tools.jar' seems to be not in Android Studio classpath.
Please ensure JAVA_HOME points to JDK rather than JRE.
Following paths are set in my Windows 8.
Path in User Variables
E:\Program Files\Java\jdk1.8.0_25\bin
JAVA_HOME in System Variables
E:\Program Files\Java\jdk1.8.0_25
Path in System Variables
E:\Program Files\Java\jdk1.8.0_25\bin
32bit JDK is installed on C drive while 64bit JDK is installed on E drive (as shown above). 32 bit JDK is not being used in any User or System Variables.
I have also restarted the PC.
How do I fix this issue?
I had this same problem and was able to fix it after wasting about 3 hours:
Just copy tools.jar from %JAVA_HOME%\lib to (Android Studio Root)\lib
check your JAVA_HOME value!
it should be like this
E:\Program Files\Java\jdk1.8.0_25\jre
First locate in your PC the route of your JDK (for instance: C:\Program Files\Java\jdk1.7.0_45)
then change the JAVA_HOME variable as follows:
Right-click the My Computer icon on your desktop and select Properties
Click the Advanced tab
Click the Environment Variables button
Under System Variables, click New
Enter the variable name as JAVA_HOME
Enter the variable value as the installation path for the Java Development Kit
I installed jdk 1.8.0_51 64bit on Windows7.
After that, no JAVA_HOME was defined, so I had to define it myself as described above, but it did not work unless I added a trailing backslash:
D:\Programs\Java\jdk1.8.0_51\.
Without the backslash at the end it did not work.
Known issue - my solution was to install JDK 7u80 - worked after that.
https://code.google.com/p/android/issues/detail?id=187048
Just Copy the tools.jar from your jdk to Android lib directory.
In my case I've installed newest Java version without uninstalling older version first. After I've uninstalled the older Java version this error was gone.
Also make sure your JAVA_HOME system variable is set properly, e.g.:
Variable Name: JAVA_HOME
Variable Value: C:\Program Files\Java\jdk1.8.0_31\
And finally, that you've installed proper version for your OS, x86 or x64.
I had exactly the same problem.
In my case I finally installed JRE to "C:\Program Files..." and the JDK to my default destination , which is "E:\Program Files..."
It seems that the JDK and JRE cannot point to the same place for Android Studio .
I had the same issue on windows 7 when I installed Android Studio. I had Jdk 8 on my system. So for me, copying the tools.jar from jdk\lib to androidstudio\lib worked. I found the tools.jar was missing from androidstudio's lib directory. I had set JAVA_HOME in user variable and JDK in system variable.
I had the same error -- tools.jar seems to be not in Studio classpath. Please ensure JAVA_HOME points to JDK rather than JRE.
I have a few Java JDKs downloaded. JAVA_HOME was pointing to C:\java\jdk1.7.0_45. When I switched to C:\java\jdk1.7.0_75, it worked. It makes no sense - both have lib/tools.jar. I did a jar tvf on each of the tools.jar files and they were fine. I ran java -version on each java & it ran ok. Dunno - makes no sense.
Platform: Windows 7 Professional - 64-bit v1.10.00.AG B11 Service Pack 1
Installing it to the default installation path instead of a custom one did solve the issue for me.
Source: https://code.google.com/p/android/issues/detail?id=187048#c9
First locate in your PC the route of your JDK (for instance: First locate in your PC the route of your JDK (for instance: C:\Program Files\Java\jdk1.8.0_11)
then change the JAVA_HOME variable as follows:
Right-click the My Computer icon on your desktop and select Properties
Click the Advanced tab
Click the Environment Variables button
Under System Variables, click New or edit it if there already a path for it ( you should make sure that the path is jdk)
Enter the variable name as JAVA_HOME
Enter the variable value as the installation path for the Java Development Kit)
1) Just install JDK from here
2) Change JAVA_HOME variable (e.g. C:\Program Files\Java\jdk1.8.0_112)
I add a similar problem on Linux.
In my case my JAVA_HOME env was pointing to the JRE HOME instead of the JDK HOME.
On my linux system I had done:
sabayon ~ # eselect java-vm list
Available Java Virtual Machines:
[1] icedtea-bin-8
[2] oracle-jdk-bin-1.8
[3] oracle-jre-bin-1.8 system-vm
sabayon ~ # eselect java-vm set system 2
And then Android Studio started like a charm. Download and install the SDK.
After I set JAVA_HOME variable and restart my windows pc I resolved my issue.
JAVA_HOME value should like below.
C:\Program Files\Java\jdk1.8.0_25\bin
I paste a screenshot for someone's help.
You can go here From My Computer / This PC > Property > Advance Variable.
I recently came across this issue while using a Managed Software solution. The company I was working with had Android Studio has part of their managed applications, however, it was a much older version that the latest release. When you use an older version of Android Studio coupled with a newer JDK (I tried 11 and 15) you then receive the error indicating tools.jar cannot be found in CLASSPATH. I resolved this by downloading the latest version from Android Studio's website and it worked like a charm!
I tried everything I could but it didn't help. So I reinstalled Windows and installed Android Studio and now everything works.
And the irony is, there is no JAVA_HOME or JDK_HOME variable defined but it still works.