Flutter : Android license status unknown - java

I have seen similar issues but they somehow could not resolve my issue.
I am currently using Windows and Versions Java 8, Java SDK 13.0.1, Android Studio v3.5.2.
1) I First typed flutter doctor and got the following error : Android license status unknown.
2) I then entered flutter doctor --android-licenses and got the following command
A newer version of the Android SDK is required. To update, run:
C:\Users\user\AppData\Local\Android\sdk\tools\bin\sdkmanager --update
3) Running this line I ended up here :
D:\flutter\flutter>C:\Users\user\AppData\Local\Android\sdk\tools\bin\sdkmanager --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: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
Please let me know the simple steps i could follow as I am confused about this a lot!

To resolve, try running flutter doctor --android-licenses. This should prompt you to accept licenses just type y and enter to accept the licence if error persists check out this issue

Related

"java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema" when accepting SDK licenses

Alright so I'm trying to build my React-Native app using Android Studio. I first ran into this error when building:
Failed to install the following Android SDK packages as some licences have not been accepted.
build-tools;29.0.2 Android SDK Build-Tools 29.0.2
To build this project, accept the SDK license agreements and install the missing components using the Android Studio SDK Manager.
Alternatively, to transfer the license agreements from one workstation to another, see http://d.android.com/r/studio-ui/export-licenses.html
Using Android SDK: C:\Users\jaspe\AppData\Local\Android\Sdk
When figuring that out I came across this answer which told me to accept the licenses. However in trying to do so I got the following error:
C:\Users\jaspe\AppData\Local\Android\Sdk\tools\bin>sdkmanager --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:581)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
... 5 more
To resolve which I found this post. I don't use brew, but I tried the second answer. It didn't work, sadly enough. Then I found out I didn't have a JDK installed, so I did that. But with the newest JDK installed I still get an exception:
C:\Users\jaspe\AppData\Local\Android\Sdk\tools\bin>sdkmanager.bat -licenses
Error occurred during initialization of boot layer
java.lang.module.FindException: Module java.xml.bind not found
And now I'm not sure what to do anymore. I found an answer explaining I needed to edit my project settings, but I think this doesn't apply to my project, and honestly I'm in a bit over my head. Does someone have experiences with these errors, and can help me fix them? I've spent the whole morning trying to figure this out, I'd expected building a runnable .APK as a demo would be easier...
You are using the wrong sdkmanager, tools directory has been deprecated
Open Android Studio and install the latest command-line tools:
This will create this folder in your Android SDK:
...\Android\Sdk\cmdline-tools\latest\bin
Now use the sdkmanager which is inside the bin directory to accept all the licenses:
C:\Users\jaspe\AppData\Local\Android\Sdk\cmdline-tools\latest\bin>sdkmanager.bat --licenses
#MatPag's answer has the solution I needed, but it took me a while to recognise it. Posting this answer for a specific case incase it helps someone else.
I was trying to setup Unreal Engine v4.25.4 when I encountered this error. I needed to run a batch script that came with Unreal Engine located at:
C:\Program Files\Epic Games\UE_4.25\Engine\Extras\Android\SetupAndroid.bat
which produced the error:
Android Studio Path: C:\Program Files\Android\Android Studio
Android Studio SDK Path: C:\Users\brianb\AppData\Local\Android\Sdk
Using sdkmanager: C:\Users\brianb\AppData\Local\Android\Sdk\tools\bin\sdkmanager.bat
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:581)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
... 5 more
Update failed. Please check the Android Studio install.
Press any key to continue . . .
Even after I located the sdkmanager.bat script and executed it according to MatPag's answer, my AndroidSetup.bat script was failing.
Eventually I realised the AndroidSetup.bat was trying to call the sdkmanager.bat from the wrong location.
I edited the AndroidSetup.bat file (line 61) as follows to correct the path:
:: set SDKMANAGER=%STUDIO_SDK_PATH%\tools\bin\sdkmanager.bat
set SDKMANAGER=%STUDIO_SDK_PATH%\cmdline-tools\latest\bin\sdkmanager.bat

Flutter setup, android licenses unknown, Windows, VS Code

I'm having a (seemingly common) unknown license status issue. However, common fixes have not worked, such as flutter doctor --android-licenses, which can be seen in the console output below. I have gone to the link also - not helpful.
C:\Users\anonymous\OneDrive\Documents\Frameworks\flutter>flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[!] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
X 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.
! Doctor found issues in 1 category.
C:\Users\anonymous\OneDrive\Documents\Frameworks\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:581)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
... 5 more
Any and all help will be greatly appreciated. Many thanks in advance :)
Installing the Android SDK Command-line Tools should fix the issue. Navigatie to settings,Appearance & Behavior -> System Settings -> Android SDK
Then run:
flutter doctor --android-licenses
Which should give you something like this:
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

Cant run flutter doctor - - license

C:\Users\USER>flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 2.0.6, on Microsoft Windows [Version 10.0.19042.928], locale en-US)
[!] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
X 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.
[√] Chrome - develop for the web
[√] Android Studio
[√] VS Code (version 1.56.1)
[√] Connected device (2 available)
! Doctor found issues in 1 category.
C:\Users\USER>flutter doctor --android-licenses
Error: Could not find or load main class J\AppData\Local\Android\Sdk\cmdline-tools\latest\bin\\..
Caused by: java.lang.ClassNotFoundException: J\AppData\Local\Android\Sdk\cmdline-tools\latest\bin\\//
EDIT 1:
I tried reinstalling sdk (after deleting files completely from appdata/android/sdk). it kinda worked but now new error is showing.:
C:\Users\USER>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:581)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
... 5 more
After a lot of searching and a lot of diff types of error ranging from environmental variable errors and java errors, i just uninstalled android studio, java and flutter files
deleted appdatas etc. and reinstalled it again now flutter doctors works fine.
i know this is not a good solution but someone could try this if all else fails.
thks
The crux of this issue seem to be with spaces in the Android SDK path, e.g. if your user name on windows is "John Smith", it will fail to detect the android SDK. The solution is to move 'C:\Users\John Smith\AppData\Local\Android\Sdk' to a path with no spaces, e.g. 'C:\Android\Sdk'. Then run the following
flutter config --android-sdk "C:\Android\Sdk"
PS: for a related issue where it says "[!] Android Studio (not installed)", run the following to manually point it to the default Android Studio install location
flutter config --android-studio-dir "C:\Program Files\Android\Android Studio"

How to fix "flutter doctor --android-licenses" java error? Without android studio

When I try to accept android licenses using command flutter doctor --android-licenses a java error is thrown.
Here is java 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:602)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
... 5 more
Here is my output for flutter doctor -v:
How can I solve above java error?
Note: I want to solve this problem without using Android Studio.
The problem is happened because when running flutter doctor --android-licenses, it implicitly running the sdk tools which is only works with JDK 8 (afaik, correct me if I'm wrong).
So, you need to install JDK 8 and set your JAVA_HOME to your JDK 8 installation path.

Flutter A newer version of the Android SDK is required. To update, run: error?

I install flutter but give some error. I know a lot of solution for this error but them are not fix for me. How can ı solve this problem ?
My JAVA_HOME at C:\Program Files\Java\jdk-13.0.2
command
C:\Users\Flamador>flutter doctor --android-licenses
A newer version of the Android SDK is required. To update, run:
C:\Users\Flamador\AppData\Local\Android\Sdk\tools\bin\sdkmanager --update
command
C:\Users\Flamador>C:\Users\Flamador\AppData\Local\Android\Sdk\tools\bin\sdkmanager
--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: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
ı try this command but ...
command
set JAVA_OPTS=-XX:+IgnoreUnrecognizedVMOptions --add-modules java.se.ee
Again
command
C:\Users\Flamador>C:\Users\Flamador\AppData\Local\Android\Sdk\tools\bin\sdkmanager --update
Error occurred during initialization of boot layer
java.lang.module.FindException: Module java.se.ee not found
Not all modules are available by default in JDK 13. To solve your problem, its a lot easier if you set your JAVA_HOME to JDK 1.8 and run the update command.

Categories

Resources