Cannot run flutter doctor --android-licenses - java

I want to use flutter on my computer, I use Android Studio and Visual Studio Code. when I was running a flutter doctor, a warning like this appeared,
[√] Flutter (Channel stable, v1.17.3, on Microsoft Windows [Version 10.0.14393], locale id-ID)
[!] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
X Android license status unknown.
Try re-installing or updating your Android SDK Manager.
See https://developer.android.com/studio/#downloads or visit visit
https://flutter.dev/docs/get-started/install/windows#android-setup for detailed instructions.
[√] Android Studio (version 4.0)
[√] VS Code (version 1.45.1)
[!] Connected device
! No devices available
! Doctor found issues in 2 categories.
but when there I run the flutter doctor --android-licenses there is an error like this, and the error is the same as I run the command sdkmanager
C:\Users\Halim>flutter doctor --android-licenses
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:602)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
... 5 more
in this situation I use jdk-13.0.1 and have added it to the path environment, and currently I use Windows 10
for the environment variable I use the settings as follows
ANDROID_HOME = C:\Users\Halim\AppData\Local\Android\Sdk
ANDROID_SDK_ROOT = %ANDROID_HOME%\tools
JAVA_HOME = C:\Program Files\Java\jdk-13.0.1
and this is the path on my Windows 10
%USERPROFILE%\AppData\Local\Microsoft\WindowsApps
C:\Users\Halim\AppData\Local\Programs\Microsoft VS Code\bin
C:\Users\Halim\AppData\Roaming\npm
%ANDROID_HOME%\platform-tools
%ANDROID_SDK_ROOT%\bin
%ANDROID_HOME%\tools
C:\Program Files\nodejs
%JAVA_HOME%\bin
C:\xampp\php
C:\flutter\bin

Try to use java 1.8 instead of 13.0.1, that might solve your problem.
This error is similiar to this one:
Flutter A newer version of the Android SDK is required. To update, run: error?

I faced this issue and solved it by these two steps:
I've read in some articles that API level 29 Android 10.0 (Q) must be installed so I downloaded it
I've uninstalled my Java JDK version 10 installation and installed JDK version 8 and set the JAVA_HOME and PATH environmental variables.
I run flutter doctor --android-licenses .
The exceptions was gone and I accepted all licences.
Done.

Had the same problem on Linux. Thats bc he couldn't access file.
solved with
flutter doctor --android-licenses

Related

How to fix ERROR: JAVA_HOME is set to an invalid directory (Flutter android licenses)

This whole issue occurred when i ran flutter doctor in cmd.Flutter doctor showed issue as:
Android toolchain - develop for Android devices (Android SDK Version 30.0.3)
Android license status unknown.
Run flutter doctor --android-licenses to accept the SDK licenses.
See https://flutter.dev/docs/get-started/install/windows#android-setup for more details.
So, I ran flutter doctor --android-licenses then it showed output as:
ERROR: JAVA_HOME is set to an invalid directory: C:\Program Files\Java\jdk-16.0.1\bin
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation.
I have tried many methods like: change the directory to C:\Program Files\Java\jdk-16.0.1 (no bin) but then when i run flutter doctor --android-licenses it shows
Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema
at com.android.repository.api.SchemaModule$SchemaModuleVersion.(SchemaModule.java:156)
at com.android.repository.api.SchemaModule.(SchemaModule.java:75)
at com.android.sdklib.repository.AndroidSdkHandler.(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:636)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:182)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:519)
... 5 more
Please help me solve this issue, Thank You!
First of all you need to install "Android SDK Command Line Tool" in andriod studio.
Settings > System Settings > Android SDK > SDK Tool --> Android SDK Command Line Tool (as shown in the following screenshot)
Then watch this video -> https://www.youtube.com/watch?v=104dNWmM6Rs&ab_channel=CodeJava
I ran same issue like this and spend couple of hour on it and finally solved it. I am sharing my solution as someone might get beneficial.
First Issue : When i ran flutter doctor --android-licenses, i got below error.
Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema
Second Issue : Then i thought it would be lack of jdk so i install jdk 8 , setup JAVA_HOME environment variable and ran flutter doctor --android-licenses , i got another error shown below.
ERROR: JAVA_HOME is set to an invalid directory: C:\Program Files\Java\jdk-jdk1.8.0_29
Please set the JAVA_HOME variable in your environment to match the location of your Java installation.
Solution : I installed Android SDK command line tool as shown in screenshot above in Android Studio and removed JAVA_HOME environment variable. Then i restart my laptop and it works. This issue has been discussed on flutter official github so here is the link https://github.com/flutter/flutter/issues/84325. I thank to TahaTesser and Pasindu Dilanka.
Conclusion :
There is no need to setup external jdk, as
default JDK that comes
with Android Studio itself, which is java 11.
TahaTesser
I have face this issue before. Just open command prompt and run it as administrator.
After that just type flutter doctor --android-licenses in the command prompt. That's all. Thank me later

Android license status unknown. Try re-installing or updating your Android SDK Manager

My app were running absolutely fine before and I do not get what was the problem later on. There were no updates in any files. I got an error in D:\src-flutter\Flutter-Projects\testing_app\android\app\build.gradle file. I tried solving it using many links.
Here is the command line implementation: \
D:\src-flutter\flutter>flutter --version
Flutter 1.17.5 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 8af6b2f038 (8 days ago) • 2020-06-30 12:53:55 -0700
Engine • revision ee76268252
Tools • Dart 2.8.4
D:\src-flutter\flutter>java -version
java version "10.0.2" 2018-07-17
Java(TM) SE Runtime Environment 18.3 (build 10.0.2+13)
Java HotSpot(TM) 64-Bit Server VM 18.3 (build 10.0.2+13, mixed mode)
D:\src-flutter\flutter>flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, v1.17.5, on Microsoft Windows [Version 10.0.18363.900], locale en-IN)
[!] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
X Android license status unknown.
Try re-installing or updating your Android SDK Manager.
See https://developer.android.com/studio/#downloads or visit visit
https://flutter.dev/docs/get-started/install/windows#android-setup for detailed instructions.
[√] Android Studio (version 4.0)
[√] Connected device (1 available)
! Doctor found issues in 1 category.
Typing flutter doctor --android-licenses does not work.
D:\src-flutter\flutter>flutter doctor --android-licenses
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:602)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
... 5 more
Hiding the obsolete packages does not give me an option of Android SDK tools.
Any help would be appreciated.
Caused by: java.lang.ClassNotFoundException
Verify the specified class name and check whether or not the .jar file exists in the classpath. If it already exists, then make sure that it is not overridden in your program. If the file does not​ exist, then simply add the .jar file in the classpath.

Try re-installing or updating your Android SDK Manager

I am trying to install Flutter Enviroment and I found this error when I use this command:
[√] Flutter (Channel stable, v1.12.13+hotfix.8, on Microsoft Windows [Version 10.0.18362.720], locale en-US)
[!] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
X 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.
[√] Android Studio (version 3.6)
[√] VS Code (version 1.43.1)
[!] Connected device
! No devices available
So When I use flutter doctor --android-licenses I found this error also:
A newer version of the Android SDK is required. To update, run:
C:\Users\DELL\AppData\Local\Android\Sdk\tools\bin\sdkmanager --update
When I tried to run this command C:\Users\DELL\AppData\Local\Android\Sdk\tools\bin\sdkmanager --update I found this error:
Error: Could not find or load main class '-XX:+IgnoreUnrecognizedVMOptions
Caused by: java.lang.ClassNotFoundException: '-XX:+IgnoreUnrecognizedVMOptions
So any one knows hoe to solve this problem
Go to the directory C:\Users\DELL\AppData\Local\Android\Sdk\tools\bin\
and then write the command:
sdkmanager --update
After that, run:
flutter doctor --android-licenses
You don't need to reinstall flutter.
You should just go to android studio->sdk manager-> sdk tools-> clear tick from Hide Obsolete Packages and tick Android Sdk tools (Obsolete) in order to install.
Finally it will be installed and you will able use flutter.
P.s. Don't forget to run to flutter doctor)
The Screenshot
Navigate in cmd to the needed folder. I think it was:
cd C:\Users\DELL\AppData\Local\Android\Sdk\tools\bin\sdkmanager --update
After this run the flutter doctor command.

Android license status unknown and a weird problem

Steps to Reproduce
I am running flutter in windows 10. I previously had a running android setup. After cloning the flutter repo and updating path, I ran flutter doctor -v. The logs are below. Now after searching a bit for solving the problem, I came across to this solution from various stackoverflow answers: Flutter.io Android License Status Unknown
I at first executed this:
set JAVA_OPTS=-XX:+IgnoreUnrecognizedVMOptions --add-modules java.se.ee
Though I don't know how to make it permanent. Then after running flutter doctor again, I came with another message, see log ###2
So it says Some Android licenses not accepted. To resolve this, run: flutter doctor --android-licenses
[!] Android Studio (version 3.4). So I ran flutter doctor --android-licenses accordingly. And it gives another error, that is:
A newer version of the Android SDK is required. To update, run:
C:\Users\imazi\AppData\Local\Android\sdk\tools\bin\sdkmanager --update
Well, so I ran C:\Users\imazi\AppData\Local\Android\sdk\tools\bin\sdkmanager --update to update it. And it kinda updated successfully outputting [=======================================] 100% Computing updates...
So I thought the issue is solved and ran flutter doctor again but it seems that nothing has been changed the problem still remains. It is like a loop. I do everything and the problem remains as it is. The output of the last flutter doctor is in log ### 3
My java version is:
10.0.2 2018-07-17
Java(TM) SE Runtime Environment 18.3 (build 10.0.2+13)
Java HotSpot(TM) 64-Bit Server VM 18.3 (build 10.0.2+13, mixed mode)
Please help.
!! also opened a github issue here: https://github.com/flutter/flutter/issues/39637
Logs
1 flutter doctor -v
O:\Flutter installation>flutter doctor -v
[√] Flutter (Channel stable, v1.7.8+hotfix.4, on Active code page: 1252
Microsoft Windows [Version 10.0.18362.295], locale en-US)
• Flutter version 1.7.8+hotfix.4 at O:\Work_Anon\Flutter installation\flutter
• Framework revision 20e59316b8 (6 weeks ago), 2019-07-18 20:04:33 -0700
• Engine revision fee001c93f
• Dart version 2.4.0
[!] Android toolchain - develop for Android devices (Android SDK version 29.0.1)
**• Android SDK at C:\Users\imazi\AppData\Local\Android\sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-29, build-tools 29.0.1
• Java binary at: O:\Work_Anon\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1343-b01)
**X 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.****
[!] Android Studio (version 3.4)
• Android Studio at O:\Work_Anon\Android Studio
X Flutter plugin not installed; this adds Flutter specific functionality.
X Dart plugin not installed; this adds Dart specific functionality.
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1343-b01)
[!] Connected device
! No devices available
2 flutter doctor after set JAVA_OPTS=-XX:+IgnoreUnrecognizedVMOptions --add-modules java.se.ee
[√] Flutter (Channel stable, v1.7.8+hotfix.4, on Active code page: 1252
Microsoft Windows [Version 10.0.18362.295], locale en-US)
[!] Android toolchain - develop for Android devices (Android SDK version 29.0.1)
! Some Android licenses not accepted. To resolve this, run: flutter doctor --android-licenses
[!] Android Studio (version 3.4)
X Flutter plugin not installed; this adds Flutter specific functionality.
X Dart plugin not installed; this adds Dart specific functionality.
[!] Connected device
! No devices available
3 last flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, v1.7.8+hotfix.4, on Active code page: 1252
Microsoft Windows [Version 10.0.18362.295], locale en-US)
[!] Android toolchain - develop for Android devices (Android SDK version 29.0.1))
! Some Android licenses not accepted. To resolve this, run: flutter doctor --android-licenses
[!] Android Studio (version 3.4)
X Flutter plugin not installed; this adds Flutter specific functionality.
X Dart plugin not installed; this adds Dart specific functionality.
[!] Connected device
! No devices available
Actually, the problem got solved after installing jdk 8 and setting JAVA_HOME accordingly this new jdk. Also in the sdkmanager.bat file, located in C:\Users\username\AppData\Local\Android\Sdk\tools\bin
I added the line set JAVA_HOME="C:\Program Files\Java\jdk1.8.0_221"
No need to uninstall java 10. That solved the whole problem!
Check if the flutter path is added.
Restart your system
Then run flutter doctor --android-licenses
accept all the licenses that appear
again run flutter doctor
and check if the issue persists
I uninstall the java jdk from my system and then let my flutter doctor arise that error of " [!] Android toolchain - develop for Android devices (Android SDK version 29.0.1)"
and then followed the solution that flutter doctor was giving as it says to run the command " flutter doctor --android-licenses " and then type " y " as it says you to accept the licenses provided to solve this problem of "[!] Android toolchain - develop for Android devices (Android SDK version 29.0.1)" and then I again ran flutter doctor and the problem was resolved.

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.

Categories

Resources