flutter doctor --android-licenses gives a java error - java

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:581)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
... 5 more
I get this error above when running flutter doctor --android-licenses. Does anyone know why this is happening and how I can fix it? I'm already running it on the flutter console.

Installing Android SDK Command-line tools from Android SDK Manager did the job for me.
Open Tools > SDK Manager
From the left choose, Appearance & Behavior > System Settings > Android SDK
Select SDK Tools from the top menu
Check Android SDK Command-line tools and click 'apply'.
Alternative to step #1: WINDOWS: File > Settings (Ctrl+Alt+S) / MAC : Android Studio > Preferences
This fix works for Windows, Linux and Mac OS X.
If you are facing a problem in spite of the above steps, you can try upgrading your system to JDK 8. Official documentation of upgrading to JDK 8 is available here.

I'm a Mac user and I solve this issue.
This answer also helps Windows users and Linux users solve the issue from the user's feedback.
At the first, this is what I met for the issue
$ flutter doctor -v
And the following command is not work for my situation.
$ flutter doctor --android-licenses
The way to solve this is to install
Android SDK Command-line Tools. And how?
You just need to do it by the following two steps.
Install: Android SDK Command-line Tools
Step 1. Open SDK Manager
Top Menu -> Tools -> SDK Manager
Step 2. Install command-line tools
Unfold Appearance & Behavior
Unfold System Settings
Click Android SDK
Click tab of SDK Tools
Check Android SDK Command-line Tools (latest)
Click Apply button.
Then click OK button to finish installation.
Keep going to sign android licenses.
After Android Studio finishing install, you can do the following.
$ flutter doctor --android-licenses
After saying yes many times, all android licenses have been signed.
Check by flutter doctor again.
$ flutter doctor -v
You can see that
All Android licenses accepted.
Congratulations, you have completed this task!

i had the same problem, solved it by installing the coomand-line tools from android studio
click on file, settings then on the search bar type sdk and click in android sdk
Then click on sdk tools, check the android command-line tools box, the click on apply allow to download. then try running flutter doctor --android-licenses again on your cmd you will be prompted to accept licenses

It seems you are getting a JDK exception, it happens when you does not have JAVA_HOME setted on your system variables OR you have almost setted the JDK but in the wrong folder OR you are trying to run the SDK Manager (which allows you to accept the Android Licenses) with the wrong JDK.
In case of JDK 9 or higher:
Actually, Android SDK Manager works only with Gradle compiled on version of JDK 8 for Android development, so, if you have a most-recent JDK version already setted on system variables, consider to downgrade it to the JDK version 8.
This version works fine for me: https://www.oracle.com/java/technologies/javase/javase-jdk8-downloads.html
In case of JDK 8 already installed
If you manually extracted the JDK folder to a directory, maybe you have setted it "wrong". I mean: You pointed the wrong way to the bin Java folder, but it still works.
You have to set JAVA_HOME as the root of JDK, example:
In the JDK zipped folder, you have to extract it and point the system variable in the unzipped folder, no directly in the bin directory, you have to point JAVA_HOME as a system variable and declare the bin folder as an executable.
Examples:
Linux
In your shell configuration file:
export JAVA_HOME="/home/user/jdk1.8.0_261"
export PATH="$PATH:$JAVA_HOME/bin"
Windows
In your environment variables manager:
Set a new SYSTEM VARIABLE named JAVA_HOME
Then, edit the PATH variable and add a new register to it:
%JAVA_HOME%\bin
Actually, I don't know really how to manage JDKs in MacOS, if that is you OS, sorry :(
Hope it helps!

I recommend clearing the android-studio-dir and android-sdk settings, and let flutter automatically detects their path instead: This works for me .
flutter config --android-studio-dir=""
flutter config --android-sdk=""

On Linux
Android SDK only works with JDK 8 so uninstall your current JDK version.
Past the command and press tab for autocomplete, remove all the things that it shows you that starts with openjdk-
sudo apt remove openjdk-
and now install JDK 8
sudo apt install openjdk-8-jdk

first of all you need to know that flutter works on jdk 8, so if you have other versions installed you need to purge them so as to completely remove other versions
NOTE: this is according to my case Ubuntu 20.04, THIS IS ACCORDING TO MY SITUATION IT IS NOT GUARANTEED TO WORK FOR YOU
if you have jdk 11, to uninstall use one of the two commands depending on the one that you had installed or you can run both of them if you do not know which one of them is installed on your machine.
sudo apt purge openjdk-11-jre-headless
sudo apt purge openjdk-11-jre
if it is any other version replace 11 with that number.
if you use the default jdk then to uninstall use the following command
sudo apt purge default-jre
to make sure we remove everything related with java run this command
sudo apt auto remove
NOTE: you can run all the above commands just to be more sure you fully remove everything related with java
to verify that we have removed everything run
java -v
if you see the error below or java version then java has not been uninstalled
Unrecognized option: --version
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
but if you get response that java was not found and there are java installation suggestion it means java has been uninstalled
now we need to install jdk 8 run this command
sudo apt install openjdk-8-jre
if everything goes well reboot your machine and run flutter doctor and follow the instructions to accept the licenses
Regards, hope this post becomes helpful to you

For me, on Windows 10, the answer was simply to remove the JAVA_HOME environment variable.
This probably isn't a good idea if you're a Java developer, or you rely on some Java software to do your work, but if you're a dev that doesn't work in the Java space and you're just getting started with Flutter like I am, then go into the system environment variables and kill that one. flutter doctor --android-licenses worked like it is supposed to after I did that.

My solution was:
I had Android SDK Build-Tools, Android Emulator and Android SDK Platform-Tools installed. Also I had JAVA_HOME variable in environments variables.
So I decided to uninstall Android SDK Build-Tools, Android Emulator and Android SDK Platform-Tools and install them again. Moreover, I deleted JAVA_HOME variable. And after these operations I run flutter doctor --android-licenses in terminal. And somehow it worked out.

The above solutions totally work, but there's a solution that I see fewer times than I would expect:
sdkman => https://sdkman.io/
with such a tool installed, changing java version is quick as ( Adopt java 8 as example):
❯ sdk install java 8.0.282.hs-adpt
❯ sdk use java 8.0.282.hs-adpt

Just in case you have multiple versions of Java installed on your OS, and the active Java version is higher than the expected one, you may end up with UnsupportedClassVersionError exception.
In my MacOS case, the active Java version is Java 17.
~ java -version
openjdk version "17.0.5" 2022-10-18 LTS
OpenJDK Runtime Environment Zulu17.38+21-CA (build 17.0.5+8-LTS)
OpenJDK 64-Bit Server VM Zulu17.38+21-CA (build 17.0.5+8-LTS, mixed mode, sharing)
and the expected Java version is Java 11 as of now.
so my flutter doctor --android-licenses command ended up with following error:
flutter doctor --android-licenses
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.UnsupportedClassVersionError:
com/android/prefs/AndroidLocationsProvider has been compiled by a
more recent version of the Java Runtime (class file version 55.0),
this version of the Java Runtime only recognizes class file
versions up to 52.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:757)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:468)
at java.net.URLClassLoader.access$100(URLClassLoader.java:74)
at java.net.URLClassLoader$1.run(URLClassLoader.java:369)
at java.net.URLClassLoader$1.run(URLClassLoader.java:363)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:362)
at java.lang.ClassLoader.loadClass(ClassLoader.java:419)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352)
at java.lang.ClassLoader.loadClass(ClassLoader.java:352)
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
at java.lang.Class.privateGetMethodRecursive(Class.java:3048)
at java.lang.Class.getMethod0(Class.java:3018)
at java.lang.Class.getMethod(Class.java:1784)
at sun.launcher.LauncherHelper.validateMainClass(LauncherHelper.java:544)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:526)
Obviously, Java 11 (class file version 52.0) rather than Java 17(class file version 55.0) is required.
Solution is exporting JAVA_HOME (preferred in a command line windown) and run flutter doctor --android-licenses again, then it should work.
export JAVA_HOME=/Library/Java/JavaVirtualMachines/zulu-11.jdk/Contents/Home/
flutter doctor --android-licenses
By the way, installed Javas can be detected by Android Studio.
(Pasted my previous comment) Again, I don't think it's a good idea to remove and then re-install a new specific Java version just for the purpose of having flutter doctor --android-licenses work. Actually, it's more appropriate to switch to another Java version if you have multiple versions of Java installed, by exporting the desired one. for example:export JAVA_HOME=/Library/Java/JavaVirtualMachines/zulu-11.jdk/Contents/Home/. Internally, flutter doctor will check JAVA_HOME for the target Java version. The benefit is obvious, the one-time export command in a command line window won't affect anything else at all.

Android Studio Electric Eel and Flutter 3.7.1
If you're facing issues after upgrading to Android Studio Electric Eel then these additional steps might help you. Usual errors after upgrading to the aforementioned Android Studio version are:
unable to locate android sdk
AndroidLocationsProvider has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0
Follow the procedure described here for installing Android SDK Command-line tools and Android SDK Manager.
Download Java JDK 19 or JDK 17 from here.
Based on the error you're getting e.g. file versions up to XY.0 you might need to install a different Java version. You can find more details on which Java version to install on Oracle - Class file format major versions and a related discussion on StackOverflow - List of Java class file format major versions.
Install the JDK on C:\Program Files\Java\java-sdk-[version].
Update your JAVA_HOME to point to the JDK. This can be achieved though the Edit System Environment Variables -> Environment Variables. You can find more on how to set the JAVA_HOME variable on Oracle - How to set the JAVA_HOME variable.
After these steps are followed, open a fresh command line and run flutter doctor --android-licenses. The error should be now resolved.

Related

Error running Flutter Doctor on M1 Mac - Unable to find bundled Java version

How do i solve this ? I've downloaded Android Studio Preview on my M1 Mac as suggested
error after running flutter doctor
The operation couldn’t be completed. Unable to locate a Java Runtime.
Please visit http://www.java.com for information on installing Java.
[✓] Flutter (Channel beta, 2.3.0-24.1.pre, on macOS 11.4 20F71 darwin-arm,
locale fr-FR)
[✗] Android toolchain - develop for Android devices
✗ cmdline-tools component is missing
Run `path/to/sdkmanager --install "cmdline-tools;latest"`
See https://developer.android.com/studio/command-line for more details.
[✓] Xcode - develop for iOS and macOS
[✓] Chrome - develop for the web
[!] Android Studio
✗ Unable to find bundled Java version.
[✓] VS Code (version 1.58.2)
[✓] Connected device (2 available)
why is it still not working ?
I've been using SDK Man for years to install, update and change java versions with simple commands. It will take care of the installation and environment variable setup as well.
Here is a simple guide for mac users
Once the sdkman is installed, you can use it from the commandline:
sdk ls java
It will return a table with all the available versions.
The cleanest choice is the lastest 'official' LTS version, where the vendor is Java.net and the current latest version is 11.0.11-open
Sdkman also helps you with a command sample at the bottom of the table, so for the current latest LTS openJDK, I would go with:
sdk install java 11.0.11-open
And that's all. Or if you have previously installed java versions (installed through other means) it is best to remove them.
Make sure you have a JDK installed (you can get it here) and your $PATH and $JAVA_HOME are set up correctly. These sources can really help:
https://mkyong.com/java/how-to-set-java_home-environment-variable-on-mac-os-x/#what-is-usrlibexecjava-home
http://www.sajeconsultants.com/how-to-set-java_home-on-mac-os-x/
https://docs.oracle.com/javase/9/install/installation-jdk-and-jre-macos.htm#JSJIG-GUID-5F4A0659-BFC5-4CB9-9920-D2DEABF29894
https://medium.com/notes-for-geeks/java-home-and-java-home-on-macos-f246cab643bd
In case you've already set them up, double check what's going on with your JAVA_HOME by pasting this in terminal:
echo $JAVA_HOME
It should output a path like this (the jdk version may vary):
/Library/Java/JavaVirtualMachines/jdk-16.0.2.jdk/Contents/Home
If it the path looks the same (or same with different java version), and you have also checked "where java", "java -version" etc, to make sure that the terminal recognises your java well and there is no other obvious java issue, that means that the only thing left is to run these commands one by one:
cd /Applications/Android\ Studio.app/Contents/jre
ln -s ../jre jdk
ln -s "/Library/Internet Plug-Ins/JavaAppletPlugin.plugin" jdk
Now if you run "flutter doctor -v", you should see no java errors and something like this instead of the previous error:
• Java binary at: /Applications/AndroidStudio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7281165)
Hope this helps! It solved the issue for me :)
These answers might help too:
Unable to find bundled Java version. MacBook Air M1
Unable to find bundled Java version on Flutter
Flutter-Unable to find bundled Java version(flutter doctor), after updated android studio Arctic Fox(2020.3.1) on M1 Apple Silicon

Android Studio installs without sdkmanager

I've been programming in Flutter using macOS 10.15.3, targeting iOS devices. Today I tried installing Android Studio also, to branch out. The installation went without errors, but in Library/Android/sdk/ there is no tools subdirectory, which is a problem because sdkmanager is supposed to be found within Library/Android/sdk/tools/bin.
I noticed this because running flutter doctor gave me:
✗ Android license status unknown.
Try re-installing or updating your Android SDK Manager.
See https://developer.android.com/studio/#downloads or visit https://flutter.dev/setup/#android-setup for detailed instructions.
I tried reinstalling Android Studio (no difference). Other solutions posted online talk about the Java version, so I upgraded the JRE from 1.7 to 1.8 and tried reinstalling Android Studio (no difference), and then upgraded JDK to the latest (so now the Java version is 11.0.6) and tried installing Android Studio again (no difference). I also upgraded Flutter to v1.12.13+hotfix.8 during the above, but this error won't go away.
If I type flutter doctor --android-licenses then I get:
Android sdkmanager tool not found (/Users/macuser/Library/Android/sdk/tools/bin/sdkmanager).
Try re-installing or updating your Android SDK,
visit https://flutter.dev/setup/#android-setup for detailed instructions.
This is how I first noticed that I'm missing part of Android Studio.
I tried cheating by creating a tools/bin subdirectory myself and then copying sdkmanager from a plugin's Library/Android/sdk/cmdline-tools/latest/bin to my new Library/Android/sdk/tools/bin. However, this didn't fool Flutter. Running flutter doctor --android-licenses led to:
A newer version of the Android SDK is required. To update, run:
/Users/macuser/Library/Android/sdk/tools/bin/sdkmanager --update
This is wrong because the Android SDK is the newest.
Does anyone know why Android Studio would be consistently missing the tools/bin subdirectory and the goodies inside? Thanks and sorry if I overlooked something basic.
Update 1 (2020-02-29)
Seems like latest version of Android SDK renamed the 'Android SDK tools' package into 'Android-SDK command line tools'.
But unfortunately current stable version of the Flutter SDK (v1.12.13+hotfix.8) is not compatible with this change and it keeps showing error message.
Workaround:
As #Mark Ebden suggested, You can simply Uncheck Hide Obsolete Packages checkbox on the SDK tools page and you'll see Android SDK Tools (Obsolete) 26.1.1. Install it and you are good to go. If you find anything missing, read the following detailed instructions.
See this issue on flutter repo for more info.
Here is the complete details you want while installing android studio with latest version of Mac OS.
1. Install Android Studio stable version.
2. Open android studio
3. open SDK manager. See the screen shot below.
4. Make sure you have downloaded all required stuff. See the screenshots below.
Please note that, I am using a custom location (/Users/darish/development/sdk/android) for my Android SDK instead of the default location (Library/Android/sdk/)
5. Go to your home directory and check whether there is a .bash_profile or not. If yes, open it, if no, create one. Add the following contents to that file.
export PATH="$PATH:~/development/sdk/flutter/bin"
export ANDROID_HOME="/Users/darish/development/sdk/android"
export PATH="$PATH:$ANDROID_HOME/platform-tools"
6. Once all the above steps are done, run flutter doctor --android-licenses and accept all licenses.
flutter doctor --android-licenses
7. Now run flutter doctor to see everything ok. If you need any further assistance, let me know. :)
That's all, have a nice day :)
What worked for me:
Run flutter doctor --android-licenses -v
I got a message that goes like:
$ flutter doctor --android-licenses -v Android sdkmanager tool not
found (/Users/juarse1/Library/Android/sdk/tools/bin/sdkmanager). Try
re-installing or updating your Android SDK, visit
https://flutter.dev/setup/#android-setup for detailed instructions.
throwToolExit (package:flutter_tools/src/base/common.dart:28:3)
AndroidLicenseValidator.runLicenseManager (package:flutter_tools/src/android/android_workflow.dart:311:7)
Doctor.diagnose (package:flutter_tools/src/doctor.dart:243:38)
This is because Android SDK is not finding command tools, but this needs to be forced to pull from obsolete package, so:
3. Go to Android Studio -> Preferences -> System Settings -> Android SDK -> SDK Tools Section
4. Uncheck Hide Obsolete Packages at the bottom
5. Make sure BOTH options are checked:
Android SDK Platform-Tools AND Android SDK Tools (Obsolete)
OK, close Android Studio
Run flutter doctor --android-licenses, should work!
The problems seems to be that in java 11 ( or 9 and 10 ) the jaxb libs are not included in the JDK and android studio sdkmanager can't read the licenses xml files.
You have to include this libs on the classpath (if you are using Java 11), you can follow the instructions posted here (it worked for me in Windows 10)
https://medium.com/#parsher/flutter-android-sdkmanager-update-with-jdk-12-ad8098165472
The last step is not necessary. After included the classpath lines, run de flutter doctor and everything should be all right.
If you are using Java 11 or higher, you just you need jaxb libraries which are not included in JDK 11/12 when it runs (especially on Win 10).
Follow the below steps:
Download wget tool from the location ->
https://eternallybored.org/misc/wget/
and set the environment variable path in your computer to run wget command in cmd prompt
Locate your Android SDSK\tools folder (<ANDROID_SDSK>\tools) and change directory to it with the cd command: cd <ANDROID_SDSK>\tools
Execute the below commands inside the tools folder:
mkdir jaxb_lib
wget https://repo1.maven.org/maven2/javax/activation/activation/1.1/activation-1.1.jar -O jaxb_lib/activation.jar
wget https://repo1.maven.org/maven2/com/sun/xml/bind/jaxb-xjc/2.3.2/jaxb-xjc-2.3.2.jar -O jaxb_lib/jaxb-xjc.jar
wget https://repo1.maven.org/maven2/com/sun/xml/bind/jaxb-core/2.3.0.1/jaxb-core-2.3.0.1.jar -O jaxb_lib/jaxb-core.jar
wget https://repo1.maven.org/maven2/org/glassfish/jaxb/jaxb-jxc/2.3.2/jaxb-jxc-2.3.2.jar -O jaxb_lib/jaxb-jxc.jar
wget https://repo1.maven.org/maven2/javax/xml/bind/jaxb-api/2.3.1/jaxb-api-2.3.1.jar -O jaxb_lib/jaxb-api.jar
wget https://repo1.maven.org/maven2/com/sun/xml/bind/jaxb-impl/2.3.2/jaxb-impl-2.3.2.jar -O jaxb_lib/jaxb-impl.jar
wget https://repo1.maven.org/maven2/com/sun/istack/istack-commons-runtime/3.0.8/istack-commons-runtime-3.0.8.jar -O jaxb_lib/istack-commons-runtime.jar
Goto the <ANDROID_SDSK>\tools\bin folder and edit sdkmanager.bat and avdmanager.bat files with your favourite text editor (notepad will do).
Paste the below code before the statement ‘#rem Execute sdkmanager’ to set classpath.
set CLASSPATH=%CLASSPATH%;%APP_HOME%\jaxb_lib\jaxb-api.jar
set CLASSPATH=%CLASSPATH%;%APP_HOME%\jaxb_lib\jaxb-core.jar
set CLASSPATH=%CLASSPATH%;%APP_HOME%\jaxb_lib\jaxb-impl.jar
set CLASSPATH=%CLASSPATH%;%APP_HOME%\jaxb_lib\jaxb-jxc.jar
set CLASSPATH=%CLASSPATH%;%APP_HOME%\jaxb_lib\jaxb-xjc.jar
set CLASSPATH=%CLASSPATH%;%APP_HOME%\jaxb_lib\activation.jar
set CLASSPATH=%CLASSPATH%;%APP_HOME%\jaxb_lib\istack-commons-runtime.jar
Finally execute: <ANDROID_SDSK>\tools\bin\sdkmanager --update
We are all done. Now run flutter doctor and now your android license status error should go away. Cheers!!!

Flutter.io Android License Status Unknown

>[!] Android toolchain - develop for Android devices (Android SDK 27.0.3)
>>• Android SDK a ..\Android\sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-27, build-tools 27.0.3
• Java binary at C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1024-b02)
X Android license status unknown.
I am getting an error with Android SDK when I run Flutter doctor, although I can still build/run it on my device. I was just curious about how to fix this issue. I believe I have the most updated version of the Android SDK downloaded, not sure what happened because I didn't have this issue last week.
##New Issues
After following several possible fixes in the comments it has led to a new problem. I installed newer versions of android sdk P, 8, and 7 along with a new jdk10. Still not updated enough apparently.
C:\Flutter\flutter>flutter doctor --android-licenses
A newer version of the Android SDK is required. To update, run:
C:\Users\tdmil\AppData\Local\Android\sdk\tools\bin\sdkmanager --update
C:\Flutter\flutter>C:\users\username\appdata\local\android\sdk\tools\bin\sdkmanager.bat --update
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
Just install the sdk command line tool(latest) the below in android studio.
Then run:
flutter doctor --android-licenses
After which you should get:
coolcoders#myhost ~ % flutter doctor --android-licenses
5 of 7 SDK package licenses not accepted. 100% Computing updates...
Review licenses that have not been accepted (y/N)? y
...and then you'll get a whole bunch of licenses to read whilst you sip your favourite beverage.
If you updated the android SDK, the licenses may have changed. Depending on how you did the update you may or may not have been prompted to accept the changes, or maybe it just doesn't save the fact that you did accept them in a way flutter can understand.
To resolve, try running
flutter doctor --android-licenses
This should prompt you to accept licenses (it may ask you first, in case just type y and press enter - although it should tell you that).
If you still have problems after doing that, it might be worth either opening a new bug in the Flutter Github repository, or adding a comment on an existing issue like this one as it may be what you're seeing.
The 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
is occurring because the current SDK version is incompatible with Java 9.
So, to solve it, you can downgrade your java version to Java 8, or with a workaround, you can export the following option on your terminal:
Linux:
export JAVA_OPTS='-XX:+IgnoreUnrecognizedVMOptions --add-modules java.se.ee'
Windows:
set JAVA_OPTS='-XX:+IgnoreUnrecognizedVMOptions --add-modules java.se.ee'
And to make it stick, you can export the JAVA_OPTS in your profile file on Linux (.zshrc, .bashrc and etc.) or add as an environment permanently on Windows.
Then, you can type the flutter or sdkmanager command:
Flutter:
flutter doctor --android-licenses
sdkmanager:
sdkmanager --licenses
and type Y when needed to accept the licenses.
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
The right solution would be if you have android studio installed then
open SDK manager
under SDK tools uncheck hide obsolete packages at the bottom
then you should see an option called Android SDK Tools (Obsolete)
check it and apply and let the studio download the package
once done run the command flutter doctor and it should now prompt you to run flutter doctor --android-licenses
once you run the license command accept all licenses by hitting y and it should solve the problem
I am writing this because of the frustration in installing flutter... Most issues are caused by simple configuration issues. Follow these steps to resolve your issues.
STEP 1:ANDROID LICENSES --android-licenses, will resolve most cases
Since you are here you have reached "Android License Status Unknown" issue for Android tool chain,as many suggested tryflutter doctor --android-licenses. If you are good with all the config. It should ask for an yes and press y and Voila. But if it shows a
Android sdkmanager tool not found (C\Users\__\local\Android\sdk\tools\bin\sdkmanager). Go to step two
STEP 2: SDK Manager installation from Android Studio
Open your Android Studio , File-> settings->System settings(left tab) ->Android SDK, go to SDK Tool section in that page, untick hide obsolete packages, select Android SDL tools(obsolete) and press apply.
It will install the SDK and you confirm it by going and checking if this path exists(C\Users\__\local\Android\sdk\tools\bin\sdkmanager)
STEP 3: Repeat 1
Repeat step 1 after installation in a new command line check if its working , else go to STEP 4
STEP 4: sdkmanager --update
It will ask you update the sdk, just run the command given in terminal C\Users\__\local\Android\sdk\tools\bin\sdkmanager --update. If it is running, then its cool. let it finish and repeat step 1, else if it is throwing some exceptions like java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema etc,
it means your java is not installed or not the correct version. Go to next step
STEP 5: JAVA 8.1 and JAVA_HOME path.
Install JAVA 8.1 and set JAVA_HOME path.
Make sure it is version 8.1(register free account and download from oracle the 8.1 version, remember above 11+ wont work for flutter
NOTE: by yaniv maymon:
if you already have Java installed on your computer and the sdkmanager --update still not working. go the environment variable and update the "JAVA_HOME" path to jdk folder. then exit the command prompt, open it again and run the update command –
STEP 6: Final Step
After installing and setting up path properly, run theC\Users\__\local\Android\sdk\tools\bin\sdkmanager --update command in new terminal and it will work
STEP 7: Rerun flutter doctor,
You can see it saying to run the command flutter doctor --android-licenses . so run flutter doctor --android-licenses in terminal and press y when asked
Here are the steps that solve my problem:
Open your terminal
type flutter doctor --android-licenses
press y to accept, this process may occurred several times. Done!
In my case the issue was missing Android SDK Command-line tools
I found this solution for having to use JDK 8 (you need an account to download now!) - use the embedded OpenJDK that comes with Android Studio:
Add this to your ~/.profile or similar:
# Use the JDK embedded with Android Studio for command-line builds
export JAVA_HOME='/Applications/Android Studio.app/Contents/jre/jdk/Contents/Home'
Command-line builds via gradlew, and any other well-behaved script, will then use the version of the SDK that ships with Android Studio 2.2+.
*My Mac was still using the default Java 7.
This was also my issue same as #16025
For an Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema
This issue seems usually happens when you've installed Java 9 before. BTW it's not compatible with android-sdk try to remove Java 9 JDK if still exist.
In general JAXB APIs are considered to be Java EE APIs, and therefore
are no longer contained on the default class path in Java SE 9. Java
9 introduces the concepts of modules, and by default the java.se
aggregate module is available on the class path (or rather, module
path). As the name implies, the java.se aggregate module does not
include the Java EE APIs that have been traditionally bundled with
Java 6/7/8. Fortunately, these Java EE APIs that were provided in
JDK 6/7/8 are still in the JDK, but they just aren't on the class path
by default. The extra Java EE APIs are provided in the following
modules
Solution to workaround if you have Java9/10 installed
Open sdkmanager in your editor.
Append DEFAULT_JVM_OPTS
Replace
DEFAULT_JVM_OPTS='"-Dcom.android.sdklib.toolsdir=$APP_HOME"'
With this one
DEFAULT_JVM_OPTS='"-Dcom.android.sdklib.toolsdir=$APP_HOME" -XX:+IgnoreUnrecognizedVMOptions --add-modules java.se.ee'
Save the file and quit the editor then try run the command again.
For Android license status unknown issue, I've tried to solve by these steps:
Open a terminal
Go to your Android SDK location
C:\Users%user%\AppData\Local\Android\Sdk\tools\bin or
~/Library/Android/sdk/tools/bin
Run the command:
./sdkmanager --license
References
Failed to run sdkmanager --list (Android SDK) with Java 9
How to resolve java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException in Java 9
here is my solution:
install SDKMan
$ curl -s "https://get.sdkman.io" | bash
setting your bash_profile
$ source "$HOME/.sdkman/bin/sdkman-init.sh
$ source ~/.bash_profile
find java sdk, and select want to install version
$ sdk ls java
$ sdk install java 8.0.192-zulu
copy your flutter doctor warning message to update sdkmanager
$ /Users/YourUserName/Library/Android/sdk/tools/bin/sdkmanager --update
after 1~4, redo it
$ flutter doctor --android-licenses
This line provided on GitHub issue community fixed my problem, here it is just in case it helps anyone else.
#rem Execute sdkmanager
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% -XX:+IgnoreUnrecognizedVMOptions --add-modules java.se.ee %JAVA_OPTS% %SDKMANAGER_OPTS% -classpath "%CLASSPATH%" com.android.sdklib.tool.sdkmanager.SdkManagerCli %CMD_LINE_ARGS%
Refer--https://robbinespu.gitlab.io/blog/2020/03/03/flutter-issue-fixed-android-license-status-unknown-on-windows/
So here the solution, open your SDK manager then uncheck Hide Obsolete Packages
Now you’ll see Android SDK Tools (Obsolete) 26.1.1 appears. Tick that package and hit apply button then ok button. it will download sdk.
then restart Android studio
Nice, now if you run flutter doctor, you should get positive result as below
PS D:\Workplace\flutter_projects> flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, v1.12.13+hotfix.8, on Microsoft Windows [Version 10.0.18363.657], locale en-MY)
[√] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
[√] Android Studio (version 3.6)
[√] VS Code (version 1.42.1)
[√] Connected device (1 available)
• No issues found!
PS D:\Workplace\flutter_projects> flutter doctor --android-licenses -v
All SDK package licenses accepted.======] 100% Computing updates...
Run flutter doctor --android-licenses and enter Y when is asked
if needed we can download package manually here https://dl.google.com/android/repository/sdk-tools-windows-4333796.zip (for Windows user). Hope this tutorial help people who looking for solution
MacOS 10.15:
Android Studio 3.5.1:
The solution that works for me was to use the Java Environment tool jenv (installed via homebrew). This tool changes the $JAVA_HOME when one switches between java versions.
In my case I have multiple Java versions installed and the current global version in use was the default. I also found it necessary to comment out the $JAVA_HOME environment variable in my .bash_profile when using this tool.
In Terminal, I entered jenv global 1.8 to get java 1.8 running instead of a later version (I have multiple versions installed).
After that:
flutter doctor --android-licenses
OR
sdkmanager --licenses
both work fine.
Note: You may need to exit and reopen your Terminal shell if you have
to redefine the $JAVA_HOME environment variable.
For those of you who are on Linux and keep getting errors during flutter doctor --android-licenses.
I kept getting the could not create settings warning when trying to accept licenses, which I fixed by specifying SDK location:
sdkmanager --sdk_root=/home/adel/bin/android-sdk --licenses
Sdkmanager then printed: all SDK package licenses accepted.
However Flutter kept giving the android license status unknown error. And attempting to call flutter doctor --android-licenses would give me the same could not create settings error I used to get.
To fix this I edited the sdkmanager script located in ${your android tools location}/tools/bin/ and changed the last line from:
exec "$JAVACMD" "$#"
To:
exec "$JAVACMD" "$#" --sdk_root=/home/adel/bin/android-sdk
This would make Flutter call sdkmanager while passing the needed sdk_root argument, a final call to flutter doctor --android-licenses fixed the issue.
I did not have to use Java 8.
open the flutter_console.bat file from the flutter SDK root folder and run the command
flutter doctor --android-licenses
it will accept the licenses of newly downloaded updates of Android SDK. You need to run it every time whenever you download and update the Android SDK.
Try downgrading your java version, this will happen when your systems java version isn't compatible with the one from android. Once you changed you the java version just run flutter doctor it will automatically accepts the licenses.
I downgraded my Java version to 1.8 and its resolved, here is the link to download JDK8
Run the following command after installing JDK8
flutter doctor --android-licenses
My environment : Windows 10 64bit, OpenJDK 14.0.2
Initial errors are as reported above.
Error was resolved after
Replaced "C:<installation-folder>\openjdk-14.0.2_windows-x64_bin\jdk-14.0.2" with "*C:\Program Files\Android\Android Studio\jre*"
in environment variable PATH & JAVA_HOME
ran flutter doctor --android-licenses and selected y for the prompts
Same problem to me, check your java version
at least it must be 1.8
For someone who is still facing the issue:
As answered below by Tommie C, Aba and few other people, but may not be clear enough as I found it.
Try installing java 1.8 manually as described here on windows/linux: [https://www3.ntu.edu.sg/home/ehchua/programming/howto/JDK_Howto.html]
and setting $JAVA_HOME variable(jdk path).
On windows set jdk path($JAVA_HOME) : [How to set java_home on Windows 7?.
On linux: [https://askubuntu.com/questions/175514/how-to-set-java-home-for-java].
Then run flutter doctor --android-licenses and accept all the licenses. Hope it helps.
I found this solution.I download JDK 8.Then I add downloading jdk file path name of JAVA_HOME into user variables in environment variable.
I faced the same problem, like mentioned above I tried these.
Installed JDK 1.8 and set my JAVA_HOME env to 1.8 - This did not work
My Android studio didn't show any "Android SDK Tools (Obsolete)" but had had an "Android SDK Tools"
This is what worked for me:
Delete the "Android SDK Tools" from SDK Manager
Reinstall it by first deselecting the "Hide Obsolete Packages" and then select "Android SDK Tools (Obsolete)", install it.
run flutter doctor --android-licenses and select y for the prompts
run flutter doctor and everything will be fine!!!!
I was facing issue. The tools folder was also missing from the Android SDK folder. I believe tools folder appears only after installing Android SDL tools(obsolete). This option was not available for me.
Solution:
I upgraded the Java from version 8 to version 12 and I was able to install the tools. You may still get the error Some Android licenses not accepted. To resolve this, run: flutter doctor --android-licenses while giving the command flutter doctor -v. Run the command flutter doctor --android-licenses, the licences will be reviewed when you click yes every time this question appears Accept? (y/N):
Hopefully it will help someone.
If you use homebrew cask, you can do
brew cask install android-sdk
mkdir ~/Library/Android/sdk/tools
ln -s /usr/local/bin/ ~/Library/Android/sdk/tools/bin
flutter doctor --android-licenses
For Windows people a short term solution is to downgrade to JDK8. Hopefully flutter will fix the issue soon for Android SDK to be working with >JDK8.
After doing lots of analysis for my Ubuntu 20.04 I have found the solution
for me the error was /home/rk/Android/Sdk/tools/bin/sdkmanager was missing write permission.
chmod +w home/rk/Android/Sdk/tools/bin/sdkmanager
Then run the below command.
flutter doctor --android-licenses
it automatically process the licences.
Follow these simple steps.
go to tools, then SDK manager, then click on android SDK.
click SDK update sites tab.
check the checkbox that states https://..sources to be fetched using https://.
click apply and ok.
Now restart android studio.
go to SDK tools and check the checkbox that states Hide obsolete packages.
wait for about a minute or so for the packages appear.
then select a package called "android SDK tools (obsolete), and press okay.
continue to install the package.
after installation restart android studio and also restart cmd, then run flutter doctor.
it will take a couple of minutes and it should work
Even in 2021, I faced the same problem with
Android Studio - Arctic fox 2020.3.1 Patch 2
Java jdk-16.0.2
Android SDK Version 31.0.0
Flutter 2.5
I have tried the answers above except for editing the sdkmanager.bat file. But NO SUCCESS at all.
Then I upgraded flutter 2.5 to 2.5.1 using the "flutter upgrade" command. Now it is working. NO issues with the "flutter doctor" command.
In linux:20.10
Please make sure you set up the path for ANDROID_HOME, ANDROID_SDK_ROOT link
I have to update newest cmdline-tools:
path/to/sdkmanager --install "cmdline-tools;latest"
to get your path/to/sdkmanager run :
which sdkmanager
and then I can run :
flutter doctor --android-licenses
WARNING: This answer is useful if you have problems with JAVA_HOME environmental variable and the direction of that. If you do not have this problem, you should not try this solution.
If you have this error and you tried with flutter doctor --android-licenses or sdkmanager --licenses and you got a problem with your JAVA_HOME environmental variable, then you have to read this.
I have a MacOS Catalina ant I could resolve this problem successfully with the next steps:
Open your terminal
Type: open -e .bash_profile (You should see almost two environmental variables: flutter and JAVA_HOME)
Save JAVA_HOME environmental variable written there in a textEdit file if you wish and DELETE the JAVA_HOME environmental variable. Save the bash_profile.
Go to terminal again and run source $HOME/.bash_profile
Try again flutter doctor and you shouldn't see the same error any more.
Please, let me know if you have doubts.

cordova build android > check failed for JDK 1.8

I am following this tutorial on building a Cordova application. I get to the part that where I'm supposed to build, and in powershell (I'm on Windows 10) I type cordova build android and I repeatedly get this error:
ANDROID_HOME=C:\Android
JAVA_HOME=C:\Program Files\java\jdk-9.0.1
Error: Requirements check failed for JDK 1.8 or greater
I realize this question has been asked here before, but those answers do not seem to apply to me.
Things I've tried:
Uninstalling and reinstalling JDK 9
Installing JDK 8 with JDK 9 installed
As the messages says the android tools require jdk 8, not jdk9.
If you have both jdk8 and jdk9 installed, you have to check wich version is in the path and where JAVA_HOME is pointing to.
In the log you posted, I see that JAVA_HOME is leading to the JDK9.
You can either modify your globel JAVA_HOME env var to target JDK8 or you can change JAVA_HOME in powershell before you use the cordova CLI if you want to use jdk8 only for cordova:
$env:JAVA_HOME="C:\Program Files\Java\jdk1.8.0_151"
cordova build android
"! My problem was i have JDK declared at many variables. Check where declared JDK!!
Sorry for my english.

Tizen Install on Windows 10 will not recognize JDK 9 installed

I am attempting to install the 64-bit version of Tizen SDK on my Win10 Home Laptop. However, every time I get the error that I either don't have java 8+ installed or that the JAVA_HOME environmental variable isn't set right.
Now I've read other questions on this, and I've set the JDK directory as first in the "Path" environmental variable. I've added the JAVA_HOME environ. var and pointed it at my JDK directory. I've rebooted twice throughout this (just in case).
I tried to install the 32-bit version of Tizen SDK, but immediately got the error that I'm not on a 32-bit OS.
I have d/l and installed Java 9 SDK and JRE. They're in
C:\Program Files\Java\jdk-9 &
C:\Program Files\Java\jre-9 respectively.
Here's my Path variable:
Path Variable Image
Any help would be mucho appreciated!
Response on Oct, 2017:
** So far Tizen studio installer can't recognize new version of Java. **
You need to install Oracle Java 8 for now.
Additional Checklist:
[✔] Tizen developers site states "Do not install OpenJDK". Make sure you are using OracleJDK instead of OpenJDK. Related links you might see:
Forum Post
[✔] There's a Tip&Tech document on Tizen Developers
Community called 'Guide for Setting JDK'. As you are having Issues, You may check it out.
Tizen: Guide for Setting JDK
[✔] I expect you are using the Latest Tizen Studio 2.0.
Latest Tizen Studio Download Link
Cause history says, Java compatibility Defers with IDE versions:
Tizen-sdk-for-wearable-setup Installation issue because of JAVA HOME
Edit on March, 2019:
Tizen-Studio now supports OpenJDK 10
To use Tizen Studio install Oracle Java Development Kit (JDK) 8, JDK 9, or OpenJDK 10 .
Prerequisites for the Tizen Studio
OpenJDK 10 and OpenJFX Installation Guideline on Tizen Developers Site
I was stuck there for a while, too. In addition to setting JAVA_HOME to C:\Program Files\Java\jdk-12.0.1 (no bin at the end), I also added C:\Program Files\Java\jdk-12.0.1\bin to the beginning of PATH; then it worked.
I've had the same problem, therefore i installed JDK8 from oracle website and the installer works fine. (no need to reboot) If you don't need specific JDK9 stuff, go with 8 and you will be good to go. Don't forget to update JAVA_HOME and Path to point to JDK8.
I have set as user variables CLASSPATH set to C:\Program Files\Java\jre1.8.0_144\lib, JAVA_HOME set to C:\Program Files\Java\jdk1.8.0_144
As system variables i've added to the existing Path this value C:\Program Files\Java\jdk1.8.0_144\bin and JAVA_HOME the same as above (even though i'm not sure the latter one is required).
PS. I have both JDK8 and 9 installed and Windows 10 64bit. I tried installing Tizen on debian using JDK9 and i got the same error, i'm sure that using JDK8 will work (need to check installation on OSX though)
Cheers!
On my M1 Mac with macOS 12, I was having trouble getting the Tizen package manager to run. It kept giving me:
Java Development Kit (JDK) was not found on your computer. To use the Tizen Studio, you need to install the JDK 8 or later. Please go to http://www.oracle.com/technetwork/java/javase/downloads and download a JDK.
Deleting ~/.package-manager solved the issue.
In my case adding "C:\Program Files\Java\jdk-12.0.2\bin" (with the quotes) to the PATH did the trick, i.e. the installer run successfully
Information on the tizen website is incomplete. On Windows 10 using OpenJDK follow the article and you need to enter another environment and system parameters after adding Java_home.
Parameter is "PATH" value is "%JAVA_HOME%\bin" otherwise Tizen Studio installation wont recognize it.
I download the IDE of version 3.2 and install the open jdk10, IDE can load successfully, but load the emulator failed when click the tools -> emulator manager.
error: could not create the java virtual machine.
my setting:
path: %JAVA_HOME%\bin
JAVA_PATH: c\jdk-10
what's the problem here? please give some suggestions.
The only thing that worked for me in the end was:
Uninstall the recent Java version and install Java SE 8u231.
After that, I tried Tizen 1.3, and it worked.
I don't know if the newer versions works, but the above worked for me for now.

Categories

Resources