Gradle can't find tools.jar [duplicate] - java

This question already has answers here:
Gradle does not find tools.jar
(30 answers)
Closed 4 years ago.
I found this post but the answer did not solve my problem. The answers only address windows systems and provide file paths which are not helpful for the OS I am running.
I am running openSUSE Leap 15 with Java 1.8, changing the OS or Java version is not an option.
When I try to build with the command ./gradlew clean build i get the following error:
:buildtools:compileJava FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':buildtools:compileJava'.
> Could not find tools.jar. Please check that /usr/lib64/jvm/java-1.8.0-openjdk-1.8.0/jre contains a valid JDK installation.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 15.364 secs
I have checked my Java installation like this:
$> rpm -qa | grep java
javapackages-tools-5.0.0+git20180104.9367c8f6-lp150.1.2.x86_64
timezone-java-2018g-lp150.2.13.1.noarch
java-1_8_0-openjdk-1.8.0.181-lp150.2.6.1.x86_64
libjavascriptcoregtk-4_0-18-2.20.5-lp150.2.6.1.x86_64
java-1_8_0-openjdk-headless-1.8.0.181-lp150.2.6.1.x86_64
I also checked out JAVA_HOME:
$> echo $JAVA_HOME
/usr/lib64/jvm/jre-1.8.0-openjdk

The comments inspired me to find a solution. Apparently installing the package java-1_8_0-openjdk will only provide the OpenJDK 8 runtime environment. I wrongly expected it to include the development tools because of the 'jdk' in its name (Java Development Kit).
My problem was solved by simply installing the package java-1_8_0-openjdk-devel which actually includes the development tools, like this: sudo zypper in java-1_8_0-openjdk-devel.
The command zypper se jdk can help you to figure out the status of your jdk installation. After installing the package java-1_8_0-openjdk-devel you should see an i+ next to the package name. You should be able to spot the following two lines:
i+ | java-1_8_0-openjdk | OpenJDK 8 Runtime Environment | package
i+ | java-1_8_0-openjdk-devel | OpenJDK 8 Development Environment | package

Related

Grails application not running after macOS upgrade

After upgrading my macOS to Big Sur, I have not been able to run my grails application. I keep getting this error
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':server:compileGroovy'.
Could not find tools.jar. Please check that /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home contains a valid JDK installation.
I have reinstalled java, but still getting the same error.
Use this command to see java paths: /usr/libexec/java_home -V | grep jdk
Copying tools.jar in /Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/lib/ to /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/lib/ solved the problem.

Perhaps you are running on a JRE rather than a JDK [duplicate]

This question already has answers here:
Compilation error in building maven project
(3 answers)
Closed 3 years ago.
I'm running Jenkins on EC2 Suse Linux and have a Jenkins job which gives me following error:
[INFO] Compiling 1 source file to /var/lib/jenkins/workspace/sampleMulti_develop/target/classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
I verified JAVA_HOME by which java shows: /usr/bin/java, gave same path in global tool configuration. Am I missing something here?
Probably you have only the Java Runtime Environment installed (JRE).
For running Jenkins, you need the Java Development Kit (JDK) which contains the javac binary for compiling Java code.
I am no expert in SuSe but I think you can install Open JDK using this link.

can't avdmanager and other SDK tools with same java version [duplicate]

When installing the android sdk tools the following error is emitted:
java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema
Why is this happening and how can it be fixed?
Debug output:
$ java --version
java 9
Java(TM) SE Runtime Environment (build 9+181)
Java HotSpot(TM) 64-Bit Server VM (build 9+181, mixed mode)
$ brew cask install android-sdk
==> Caveats
We will install android-sdk-tools, platform-tools, and build-tools for you.
You can control android sdk packages via the sdkmanager command.
You may want to add to your profile:
'export ANDROID_SDK_ROOT=/usr/local/share/android-sdk'
This operation may take up to 10 minutes depending on your internet connection.
Please, be patient.
==> Satisfying dependencies
==> Downloading https://dl.google.com/android/repository/sdk-tools-darwin-3859397.zip
Already downloaded: /Users/tomasnovella/Library/Caches/Homebrew/Cask/android-sdk--3859397,26.0.1.zip
==> Verifying checksum for Cask android-sdk
==> Installing Cask android-sdk
==> Exception in thread "main"
==> java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema
==> at com.android.repository.api.SchemaModule$SchemaModuleVersion.<init>(SchemaModule.java:156)
==> at com.android.repository.api.SchemaModule.<init>(SchemaModule.java:75)
==> at com.android.sdklib.repository.AndroidSdkHandler.<clinit>(AndroidSdkHandler.java:81)
==> at com.android.sdklib.tool.SdkManagerCli.main(SdkManagerCli.java:117)
==> at com.android.sdklib.tool.SdkManagerCli.main(SdkManagerCli.java:93)
==> Caused by: java.lang.ClassNotFoundException: javax.xml.bind.annotation.XmlSchema
==> at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:582)
==> at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:185)
==> at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:496)
==> ... 5 more
Error: Command failed to execute!
==> Failed command:
/usr/local/Caskroom/android-sdk/3859397,26.0.1/tools/bin/sdkmanager tools platform-tools build-tools;26.0.1
==> Standard Output of failed command:
==> Standard Error of failed command:
Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema
at com.android.repository.api.SchemaModule$SchemaModuleVersion.<init>(SchemaModule.java:156)
at com.android.repository.api.SchemaModule.<init>(SchemaModule.java:75)
at com.android.sdklib.repository.AndroidSdkHandler.<clinit>(AndroidSdkHandler.java:81)
at com.android.sdklib.tool.SdkManagerCli.main(SdkManagerCli.java:117)
Just had this error, solved by downloading the Android SDK Command-line Tools (latest) on Android Studio, under Preferences > Appearance & Behavior > System Settings > Android SDK > SDK Tools and re-running flutter doctor --android-licenses
Finally, add the new tools to your PATH, in your .bashrc, .zshrc or similar, before the obsolete tools:
export PATH=$PATH:$ANDROID_HOME/cmdline-tools/latest/bin
I had a similar problem this morning (trying to build for Android using Unity3D). I ended up uninstalling JDK9 and installing Java SE Development Kit 8u144.
brew cask uninstall java # uninstall java9
brew tap homebrew/cask-versions
brew cask install java8 # install java8
touch ~/.android/repositories.cfg # without this file, error will occur on next step
brew install --cask android-sdk
I also had this error
Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema
at com.android.repository.api.SchemaModule$SchemaModuleVersion.<init>(SchemaModule.java:156)
at com.android.repository.api.SchemaModule.<init>(SchemaModule.java:75)
at com.android.sdklib.repository.AndroidSdkHandler.<clinit>(AndroidSdkHandler.java:81)
at com.android.sdklib.tool.sdkmanager.SdkManagerCli.main(SdkManagerCli.java:73)
at com.android.sdklib.tool.sdkmanager.SdkManagerCli.main(SdkManagerCli.java:48)
Caused by: java.lang.ClassNotFoundException: javax.xml.bind.annotation.XmlSchema
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:582)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:190)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:499)
... 5 more
then instead of uninstalling the latest java environment, (in my case it is java 13)
and installation of java 8,
I have done the following steps
open the android studio > go to configure > select sdk manager > go to sdk tools > make a tick on android sdk command line tools >apply > and wait for installation
restart the command line tool
enter the command flutter doctor
enter the command flutter doctor --android-licenses
and accept all the licenses by typing y.
To solve this error, you can downgrade your Java version.
Or exports the following option on your terminal:
Linux/MAC:
export JAVA_OPTS='-XX:+IgnoreUnrecognizedVMOptions --add-modules java.se.ee'
Windows:
set JAVA_OPTS=-XX:+IgnoreUnrecognizedVMOptions --add-modules java.se.ee
If this does not work try to exports the java.xml.bind instead.
Linux:
export JAVA_OPTS='-XX:+IgnoreUnrecognizedVMOptions --add-modules java.xml.bind'
Windows:
set JAVA_OPTS=-XX:+IgnoreUnrecognizedVMOptions --add-modules java.xml.bind
And to save it permanently you can exports the JAVA_OPTS in your profile file on Linux (.zshrc, .bashrc and etc.) or add it as an environment variable permanently on Windows.
ps. This doesn't work for Java 11/11+, which doesn't have Java EE modules. For this option is a good idea, downgrade your Java version or wait for a Flutter update.
Ref: JDK 11: End of the road for Java EE modules
set JAVA_OPTS=-XX:+IgnoreUnrecognizedVMOptions --add-modules java.se.ee
This fixed the problem on Windows for me.
Source 1, source 2
Update 2019-10:
As stated in the issue tracker, Google has been working on a new Android SDK Command-line Tools release that runs on current JVMs (9, 10, 11+) and does not depend on deprecated JAXB EE modules!
You can download and use the new Android SDK Command-line Tools inside Android Studio or by manually downloading them from the Google servers:
SDK Tools for Linux
SDK Tools for Mac OS
SDK Tools for Windows
For the latest versions check the URLs inside the repository.xml.
If you manually unpack the command line tools, take care of placing them in a subfolder inside your $ANDROID_HOME (e.g. $ANDROID_HOME/cmdline-tools/...).
Update 2021-03:
The latest stable command-line tools are available at Googles Downloads-Website. These tools are newer than those linked above.
If you don't want to change your Java version (I don't), you can temporarily change the version in your shell:
First run
/usr/libexec/java_home -V
Then pick a major version if you have it installed, otherwise install it first:
export JAVA_HOME=`/usr/libexec/java_home -v 1.8`
Now you can run sdkmanager.
When using Linux, an easy option is installation of JDK version 8 then selecting it as the default using:
sudo update-alternatives --config java
On Mac/Linux use the following command:
export JAVA_OPTS='-XX:+IgnoreUnrecognizedVMOptions --add-modules java.se.ee'
Works for both JDK 9 and 10, without patching any script (sdkmanager, avdmanager).
For Java 11 see: https://stackoverflow.com/a/51644855/798165
You need to add the following to your Profile (Works on MacOS):
export JAVA_HOME=`/usr/libexec/java_home -v 1.8`
No need to patch anything.
While building the flutter application an error occurred saying android sdk licenses not accepted. So, while accepting the license this error occurred.
Reason for this error in my case was I haven't installed sdkmanager command line tools which is required to accept the license.
So, to install command line tools easiest way is:
Open android studio.
Open SDK Manager (refer image below):
Select SDK tools inside it in bar.
Tick the option Android SDK Command-line Tools (latest)
Apply it.
Run flutter doctor -android-licenses if using flutter or you can continue with the process where the error occurred.
I found two answers that worked for me, without having to uninstall JDK 10 (or 9), which I need for create-react-app. Both JDK 9 and 10 are incompatible with android-sdk !
Siu Ching Pong -Asuka Kenji- suggests modifying the sdkmanager script, replacing this line:
DEFAULT_JVM_OPTS='"-Dcom.android.sdklib.toolsdir=$APP_HOME"'
with:
DEFAULT_JVM_OPTS='"-Dcom.android.sdklib.toolsdir=$APP_HOME" -XX:+IgnoreUnrecognizedVMOptions --add-modules java.se.ee'
Note that this mod will be overwritten when updating sdkmanager.
Check out his post, and the one he links to, for more details.
This solution was also one of the solutions mentioned in this github issues thread.
German's post indicates the source of the conflict, and presents fix that will not not be overwritten by updates.
He suggests renaming /Library/Java/JavaVirtualMachines/Info.plist as a means of obscuring it from the script that looks for the highest version of Java that resides on your system. In this way, JDK 8 is returned as the default.
Referring to JDK 10 explicitly, or by setting it to $JAVA_HOME, you can use JDK 10 , instead of the default, whenever needed.
Details are in his post.
Strangely Java9 is not compatible with android-sdk
$ avdmanager
Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema
at com.android.repository.api.SchemaModule$SchemaModuleVersion.<init>(SchemaModule.java:156)
at com.android.repository.api.SchemaModule.<init>(SchemaModule.java:75)
at com.android.sdklib.repository.AndroidSdkHandler.<clinit>(AndroidSdkHandler.java:81)
at com.android.sdklib.tool.AvdManagerCli.run(AvdManagerCli.java:213)
at com.android.sdklib.tool.AvdManagerCli.main(AvdManagerCli.java:200)
Caused by: java.lang.ClassNotFoundException: javax.xml.bind.annotation.XmlSchema
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:582)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:185)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:496)
... 5 more
Combined all commands into one for easy reference:
$ sudo rm -fr /Library/Java/JavaVirtualMachines/jdk-9*.jdk/
$ sudo rm -fr /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin
$ sudo rm -fr /Library/PreferencePanes/JavaControlPanel.prefPane
$ /usr/libexec/java_home -V
Unable to find any JVMs matching version "(null)".
Matching Java Virtual Machines (0):
Default Java Virtual Machines (0):
No Java runtime present, try --request to install
$ brew tap caskroom/versions
$ brew cask install java8
$ touch ~/.android/repositories.cfg
$ brew cask install android-sdk
$ echo 'export ANDROID_SDK_ROOT="/usr/local/share/android-sdk"' >> ~/.bash_profile
$ java -version
java version "1.8.0_162"
Java(TM) SE Runtime Environment (build 1.8.0_162-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.162-b12, mixed mode)
$ avdmanager
Usage:
avdmanager [global options] [action] [action options]
Global options:
-s --silent : Silent mode, shows errors only.
-v --verbose : Verbose mode, shows errors, warnings and all messages.
--clear-cache: Clear the SDK Manager repository manifest cache.
-h --help : Help on a specific command.
Valid actions are composed of a verb and an optional direct object:
- list : Lists existing targets or virtual devices.
- list avd : Lists existing Android Virtual Devices.
- list target : Lists existing targets.
- list device : Lists existing devices.
- create avd : Creates a new Android Virtual Device.
- move avd : Moves or renames an Android Virtual Device.
- delete avd : Deletes an Android Virtual Device.
I faced the same problem. Though I am a little bit backdated developer (Still using windows to develop :P)
To solve this issue on windows :
STEP 1: Install jdk 8 if it wasn't installed (jdk 9 or 11 doesn't work but you may have them installed for using in other dev uses).
Very simple using Chocolatey:
choco install jdk8
(If installed using Chocolatey, skip steps 2 and 3)
STEP 2: Go to the Environment variables settings and set JAVA_HOME TO jdk 8's installation directory.
STEP 3: Go to path variable and add bin directory of jdk 8 and move it to top.
STEP 4: Close any open terminal sessions and restart a new session
OPTIONAL STEP 5: Depending on your objective in the terminal run (may need to add sdkmanager to path or just navigate to the directory):
sdkmanager --update
That's all! :O Enjoy fluttering! :D
Since Java 11 has removed JavaEE you'll need to download some jars and add to the classpath:
JAXB:
https://javaee.github.io/jaxb-v2/
JAF:
https://www.oracle.com/technetwork/articles/java/index-135046.html
Then edit sdkmanager.bat so that set CLASSPATH=... ends with ;%CLASSPATH%
Set CLASSPATH to include JAXB and JAF:
set CLASSPATH=jaxb-core.jar;jaxb-impl.jar;jaxb-api.jar;activation.jar
Then sdkmanager.bat will work.
I ran into same issue when running:
$ /Users/<username>/Library/Android/sdk/tools/bin/sdkmanager "platforms;android-28" "build-tools;28.0.3"_
I solved it as
$ echo $JAVA_HOME
/Library/Java/JavaVirtualMachines/jdk-11.0.1.jdk/Contents/Home
$ ls /Library/Java/JavaVirtualMachines/
jdk-11.0.1.jdk
jdk1.8.0_202.jdk
Change Java to use 1.8
$ export JAVA_HOME='/Library/Java/JavaVirtualMachines/jdk1.8.0_202.jdk/Contents/Home'
Then the same command runs fine
$ /Users/<username>/Library/Android/sdk/tools/bin/sdkmanager "platforms;android-28" "build-tools;28.0.3"
In my case, I need both JDK 8 (trying to use the AVD and SDK manager in Qt under ubuntu) and 11 for different tools. Removing version 11 is not an option.
The 'JAVA_OPTS' solutions did not do anything. I don't really like the export JAVA_HOME, as it might force you do launch whatever tool calls these utils from the same shell (like Qt), or force you to make this permanent, which is not convenient.
So for me the solution is quite simple. Add something like this in the second line of ~/Android/tools/bin/sdkmanager and ~/Android/tools/bin/avdmanager:
JAVA_HOME="/usr/lib/jvm/java-8-openjdk-amd64"
(or whatever the path is to your rev 8 jdk).
With this, these command line tools work in a stand alone mode, they work also when called by other tools such as Qt, and jdk 11 is still the system default for others. No need to mix libs etc...
The only downside is that any update to these command line tools will erase these modifications, which you will have to put back in.
As of the latest version of the Android command-line tools (2.1 as of this writing), it is no longer necessary to patch sdkmanager nor to downgrade to an ancient version of Java.
Simply update your SDK packages and switch your command-line tools to the latest release, which will track new versions as they come:
sdkmanager --update
sdkmanager 'cmdline-tools;latest'
sdkmanager --uninstall 'cmdline-tools;1.0'
You may need to provide the full path to sdkmanager if it's not on your PATH, and you may need to adjust your PATH afterwards if it was referring to the 1.0 tools explicitly.
In my case, I have Java 14 and need Java 8.
I'm in a Arch Linux and has installed jdk8-openjdk jre8-openjdk https://www.archlinux.org/packages/extra/x86_64/java8-openjdk/
For Debian users https://wiki.debian.org/Java, or Fedora https://docs.fedoraproject.org/en-US/quick-docs/installing-java/.
Install Java 8 (or desired version, in this case jdk8-openjdk jre8-openjdk) using your package manager before doing the following steps.
1. Figuring out where is my Java:
# which java
/usr/bin/java
2. Checking java files:
I can see all java files here are links to /usr/lib/jvm/default[something]. This means that the java command is linked to some specific version of java executable.
# ls -l /usr/bin/java*
lrwxrwxrwx 1 root root 37 May 16 06:30 /usr/bin/java -> /usr/lib/jvm/default-runtime/bin/java
lrwxrwxrwx 1 root root 30 May 16 06:30 /usr/bin/javac -> /usr/lib/jvm/default/bin/javac
lrwxrwxrwx 1 root root 32 May 16 06:30 /usr/bin/javadoc -> /usr/lib/jvm/default/bin/javadoc
lrwxrwxrwx 1 root root 30 May 16 06:30 /usr/bin/javah -> /usr/lib/jvm/default/bin/javah
lrwxrwxrwx 1 root root 30 May 16 06:30 /usr/bin/javap -> /usr/lib/jvm/default/bin/javap
3. Checking the default and default-runtime
Here I could see the default version was linked to 14 (unique installed version).
# cd /usr/lib/jvm
# ls -l
lrwxrwxrwx 1 root root 14 Aug 8 20:44 default -> java-14-openjdk
lrwxrwxrwx 1 root root 14 Aug 8 20:44 default-runtime -> java-14-openjdk
drwxr-xr-x 7 root root 4096 Jul 19 22:38 java-14-openjdk
drwxr-xr-x 6 root root 4096 Aug 8 20:42 java-8-openjdk
4. Switching the default version
First, remove the existing default and default-runtime which linked to java-14 version.
# rm default default-runtime
Then, create new links to the desired version (in this case, java-8).
# ln -s java-8-openjdk default
# ln -s java-8-openjdk default-runtime
The strategy is to make links to the desired version of software (java8 in this case) using ln -s above. Then, this links are linked to the binaries inside the java bin directory (without changing the $PATH environment variable!)
Or you might be wanted to change the Java version using archlinux-java command instead with more safely approach: https://wiki.archlinux.org/index.php/Java
TLDR; Try setting JAVA_HOME worked fine for me on OSX
export JAVA_HOME=/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home
To install the JDKs 8 ( LTS ) from AdoptOpenJDK:
# brew tap adoptopenjdk/openjdk
brew cask install adoptopenjdk/openjdk/adoptopenjdk8
This question has numerous answers, and they're all different due to users installing different toolchains and using different Java versions.
The recommended way of using Android development toolchain, or at least the one that I suggest to use, is to follow what's stated in Android Studio documentation:
You should always keep your Build Tools component updated by downloading the latest version using the Android SDK Manager.
Android studio allows you to easily manage installed SDKs & build tools, yes, it requires some space on your hard drive, but it will save you some time. Once you get familiar with how it works, then you can think of installing command-line tools only.
If there's no particular reason of using older Java version, use the latest (stable) version, you will have interesting new features, and also the compiled application will benefit from all the new optimizations.
Fresh install
Delete your local Android folder, usually in the home directory
Download Android studio
Once installed, open Settings, Search Android SDK and open it
In SDK Platforms select the target Android version for your app
In SDK Tools tab, select Android SDK Build-Tools, Android SDK Command-line Tools (latest), Android Emulator, Android SDK Platform-Tools
Before pressing OK, check that Android SDK Location path is correct for you
Press OK and let Android Studio download & install everything
(Optional) if you need to use the installed binaries from command line, be sure to add their folder into your PATH variable. If you use Android studio, it's should not be required though.
I've got Java 14 installed on my machine, anyway you can use the jre shipped with Android Studio.
For Linux users (I'm using a Debian Distro, Kali)
Here's how I resolved mine.
If you don't already have jdk-8, you want to get it at oracle's site
https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
I got the jdk-8u191-linux-x64.tar.gz
Step 1 - Installing Java
Move and unpack it at a suitable location like so
$ mv jdk-8u191-linux-x64.tar.gz /suitablelocation/
$ tar -xzvf /suitablelocation/jdk-8u191-linux-x64.tar.gz
You should get an unzipped folder like jdk1.8.0_191
You can delete the tarball afterwards to conserve space
Step 2 - Setting up alternatives to the default java location
$ update-alternatives --install /usr/bin/java java /suitablelocation/jdk1.8.0_191/bin/java 1
$ update-alternatives --install /usr/bin/javac javac /suitablelocation/jdk1.8.0_191/bin/javac 1
Step 3 - Selecting your alternatives as default
$ update-alternatives --set java /suitablelocation/jdk1.8.0_191/bin/java
$ update-alternatives --set javac /suitablelocation/jdk1.8.0_191/bin/javac
Step 4 - Confirming default java version
$ java -version
Notes
In the original article here: https://forums.kali.org/showthread.php?41-Installing-Java-on-Kali-Linux,
the default plugin for mozilla was also set. I assume we don't really need the plugins as we're
simply trying to develop for android.
As in #spassvogel's answer, you should also place a #repositories.cfg file in your ~/.android directory
as this is needed to update the tools repo lists
Moving some things around may require root authority. Use sudo wisely.
For sdkmanager usage, see official guide: https://developer.android.com/studio/command-line/sdkmanager
In my case I didn't have the required sdk version installed on my machine.
So make sure that you have installed the sdk version which is given in the error.
Here you can navigate check & install via Android Studio.
For windows machine uninstall the JDK if its more than 1.8.172.
Install JDK 1.8.172
I was facing the same issue in windows 10 with java 10. I uninstalled the java 10 and installed java8 its working fine for me now :)
Run java -version and javac -version commands in a command line to make sure that they come from the same JDK (eg: version 1.8.0_181)
If not, you have to modify PATH variable so that it only points to a single JDK. If you are not sure how to, just uninstall all other Java instances except for Java 8 (Add/Remove Programs in Windows). As for today, both Unity and Android recommends that you use JDK 8.
With Java 8, it is not necessary to export java.se.ee module as shown in some of the other answers. You may also remove any JAVA_OPTS or other environment variables that you have set.
Downgrade your java version.Whatever system or ide.
Make sure java version is not higher than 8
In my case.I change the ide java verion.This solves my issue.
I had recently solved this problem by uninstalling the higher version of JDK and installing JDK 8. After installing the JDK you need to give the path. Then you need to open command prompt in "C:\Users\Milan Adhikari\AppData\Local\Android\Sdk\tools" and run "sdkmanager --update" which will update your sdk and then you need to run "flutter doctor --android-licenses" in cmd and accept all the licenses.
Now your problem should be solved.
Best way is to use below command
$ wget https://dl.google.com/android/repository/platform-tools-latest-linux.zip
$ unzip \platform-tools-latest-linux.zip
$ sudo cp platform-tools/adb /usr/bin/adb
$ sudo cp platform-tools/fastboot /usr/bin/fastboot
Now run adb version to verify it’s been updated.
No need to uninstall your other java version(s) that's already installed on your machine. Whenever required, you can conveniently use the utility 'update-alternatives' to choose the Java runtime that you wish to activate. It will automagically update the required symbolic links.
You just need to run the below command and select the version of your choice. That's all!
sudo update-alternatives --config java
As #steven pointed out, install Java 8 (here a link for Ubuntu 16.04, 18.04 and 20.04/20.10 https://computingforgeeks.com/how-to-install-java-8-on-ubuntu/) and then set it as the default Java version with this command:
sudo update-alternatives --config java

Gradle on macOS Hight Sierra - Java 9

I update java to the lasted version e then I following this guide to install grade using Homebrew:
gradle installation guide
When the gradle installation is finished, I tried to launch gradre using the command: grade by command line but appear this error:
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine java version from '9.0.1'.
How can I fix this problem?
It is a Gradle bug has been fixed in version 4.2.1:
https://github.com/gradle/gradle/commit/d9c35cf9d74c102641fcfe0bb7bf622791a96caf

Lib GDX html running gives an error with System Java Compiler (Eclipse) (Windows 7)

I am trying to compile a HTML project, from this youtube video. But when I am running that HTML external tool, it gives me an error:
Configuration on demand is an incubating feature.
:core:compileJava FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':core:compileJava'.
> Cannot find System Java Compiler. Ensure that you have installed a JDK (not just a JRE) and configured your JAVA_HOME system variable to point to the according directory.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 2.297 secs
I was searching on internet, but I didn't find a solution which worked for me. Can anybody help me?
hello sorry for my English, while I do not use windows, but I think you have to install the Java JDK, look for this if you do not have it, I think he had to do something like this:
1 Right-click the My Computer icon on your desktop and select Properties.
2 Click the Advanced tab.
3 Click the Environment Variables button.
4 Under System Variables, click New.
5 Enter the variable name as JAVA_HOME.
;C:\Program Files\Java\YOUR VERSION JAVA JDK \src.zip
It actually doesnt work. If i set the loc to : C:\Program Files\Java\jre7 It gives an error which i show in the first post.
If i set the loc to : C:\Program Files\Java\jre1.8.0_25\bin
ERROR: JAVA_HOME is set to an invalid directory: C:\Program Files\Java\jre1.8.0_25\bin
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation.
I tried to C:\Program Files\Java\jre1.8.0_25\libs but the same.
BTW: I dont have JDK, i have only JRE.. I downloaded an JDK from java˘s web, installed it, and in my Java folder appeared only the JRE.

Categories