Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android/Windows: sdkmanager --licenses doesn't persist when run as non-administrator #16065

Closed
natem34 opened this issue Mar 29, 2018 · 24 comments
Labels
a: first hour The first hour of using Flutter platform-android Android applications specifically tool Affects the "flutter" command-line tool. See also t: labels.

Comments

@natem34
Copy link

natem34 commented Mar 29, 2018

When I run flutter doctor, "Android licenses not accepted. To resolve this, run: flutter doctor --android-licenses" is the only thing it's cranky about. When I run the command, and hit "y" to accept each license and rerun flutter doctor, it still complains about the android licenses.

flutter doctor -v
[√] Flutter (Channel beta, v0.2.3, on Microsoft Windows [Version 10.0.16299.309], locale en-US)
    • Flutter version 0.2.3
    • Framework revision 5a58b36e36 (2 weeks ago), 2018-03-13 13:20:13 -0700
    • Engine revision e61bb9ac3a
    • Dart version 2.0.0-dev.35.flutter-290c576264

[!] Android toolchain - develop for Android devices (Android SDK 27.0.3)
    • Android SDK
    • Android NDK
    • Platform android-27, build-tools 27.0.3
    • ANDROID_HOME
    • Java binary
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1024-b02)
    X Android licenses not accepted.  To resolve this, run: flutter doctor --android-licenses

[√] Android Studio (version 3.1)
    • Android Studio
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1024-b02)

[√] VS Code, 64-bit edition (version 1.21.1)
    • VS Code
    • Dart Code extension version 2.11.1

[!] Connected devices
    ! No devices available

! Doctor found issues in 2 categories.

I posted the same thing on the Google groups for flutter, and it was suggested this is a bug and that I should post it here.

@tvolkert
Copy link
Contributor

Can you include the output of flutter --verbose doctor -v?

@tvolkert tvolkert added platform-android Android applications specifically tool Affects the "flutter" command-line tool. See also t: labels. a: first hour The first hour of using Flutter labels Mar 29, 2018
@tvolkert
Copy link
Contributor

(this is the output of flutter doctor -v, which is not as verbose)

@tvolkert
Copy link
Contributor

@cbracken suggests that this may be getting caused because you have two Android Studio installations -- Flutter detects one, and you accept licenses on another. Could that be the case?

@natem34
Copy link
Author

natem34 commented Mar 29, 2018

C:\Users\Nate>flutter --verbose doctor -v
[  +15 ms] [D:\Users\Nate\Go\src\github.com\flutter\] git rev-parse --abbrev-ref --symbolic @{u}
[  +59 ms] Exit code 0 from: git rev-parse --abbrev-ref --symbolic @{u}
[        ] origin/beta
[        ] [D:\Users\Nate\Go\src\github.com\flutter\] git rev-parse --abbrev-ref HEAD
[  +32 ms] Exit code 0 from: git rev-parse --abbrev-ref HEAD
[        ] beta
[        ] [D:\Users\Nate\Go\src\github.com\flutter\] git ls-remote --get-url origin
[  +30 ms] Exit code 0 from: git ls-remote --get-url origin
[   +1 ms] https://github.com/flutter/flutter.git
[        ] [D:\Users\Nate\Go\src\github.com\flutter\] git log -n 1 --pretty=format:%H
[  +32 ms] Exit code 0 from: git log -n 1 --pretty=format:%H
[   +1 ms] 5a58b36e36b8d7aace89d3950e6deb307956a6a0
[        ] [D:\Users\Nate\Go\src\github.com\flutter\] git log -n 1 --pretty=format:%ar
[  +31 ms] Exit code 0 from: git log -n 1 --pretty=format:%ar
[   +1 ms] 2 weeks ago
[        ] [D:\Users\Nate\Go\src\github.com\flutter\] git describe --match v*.*.* --first-parent --long --tags
[  +32 ms] Exit code 0 from: git describe --match v*.*.* --first-parent --long --tags
[   +1 ms] v0.2.3-0-g5a58b36e3
[ +404 ms] java -version
[  +82 ms] [√] Flutter (Channel beta, v0.2.3, on Microsoft Windows [Version 10.0.16299.309], locale en-US)
[   +1 ms]     • Flutter version 0.2.3 at D:\Users\Nate\Go\src\github.com\flutter
[        ]     • Framework revision 5a58b36e36 (2 weeks ago), 2018-03-13 13:20:13 -0700
[        ]     • Engine revision e61bb9ac3a
[        ]     • Dart version 2.0.0-dev.35.flutter-290c576264
-[   +1 ms] C:\AndroidStudio\sdk\tools\bin\sdkmanager --licenses
[   +2 ms] C:\AndroidStudio\sdk\platform-tools\adb devices -l
[  +26 ms] Exit code 0 from: C:\AndroidStudio\sdk\platform-tools\adb devices -l
[   +1 ms] List of devices attached
[   +7 ms] C:\AndroidStudio\sdk\platform-tools\adb devices -l
[  +60 ms] List of devices attached
[ +878 ms] [!] Android toolchain - develop for Android devices (Android SDK 27.0.3)
[        ]     • Android SDK at C:\AndroidStudio\sdk
[        ]     • Android NDK at C:\AndroidStudio\sdk\ndk-bundle
[        ]     • Platform android-27, build-tools 27.0.3
[        ]     • ANDROID_HOME = C:\AndroidStudio\sdk
[        ]     • 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 licenses not accepted.  To resolve this, run: flutter doctor --android-licenses
[        ] [√] Android Studio (version 3.1)
[        ]     • Android Studio at C:\Program Files\Android\Android Studio
[        ]     • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1024-b02)
[        ] [√] VS Code, 64-bit edition (version 1.21.1)
[        ]     • VS Code at C:\Program Files\Microsoft VS Code
[        ]     • Dart Code extension version 2.11.1
[        ] [!] Connected devices
[        ]     ! No devices available
[        ] ! Doctor found issues in 2 categories.
[  +13 ms] "flutter doctor" took 1,407ms.
[ +255 ms] ensureAnalyticsSent: 251ms
[   +1 ms] Running shutdown hooks
[        ] Shutdown hooks complete
[        ] exiting with code 0

@tvolkert
Copy link
Contributor

Thanks! One more 😄 -- can you run the following and attach the generated bug report ZIP file here?

flutter doctor --bug-report --android-licenses

@natem34
Copy link
Author

natem34 commented Mar 29, 2018

Sure, thanks for your help.
bugreport_01.zip

@Mahi-K
Copy link

Mahi-K commented Mar 30, 2018

hi, @natem34 , yes flutter complains about this issue if you have first installed it or trying run your project for the first time on any android device, i think you could try and create an android project in AndroidStudio and accept all the licenses in AndroidStudio and then run the flutter doctor -v and see if this helps. if the framework still complains about not accepting licenses, you can run flutter doctor --android-licenses and click yes to accept. Thank you , this happened to me and i did the same and its fine now.

@Herohtar
Copy link

Herohtar commented Mar 30, 2018

I think this is actually related to/duplicate of #16025.

@natem34
Copy link
Author

natem34 commented Mar 30, 2018

@Mahi-K, that a fact huh? Ok, I will try to create a new project from Android studio and see if I can accept the licenses from there. Seems weird that the instructions tell you to run flutter doctor during the setup, but doesn't say that it's cool to continue given certain errors. Oh well... I guess that's why it's in beta right? :)

@Herohtar I'll check that out. I did do a search for the issue, my apologies if I missed duplicates.

@tvolkert
Copy link
Contributor

@natem34 strange - everything in the bug report looks like it behaved normally when you accepted the licenses (assuming you hit "y" when prompted). But you're saying that if you run it again, it prompts you again like it didn't record the acceptance the first time?

@natem34
Copy link
Author

natem34 commented Apr 1, 2018

@tvolkert I did hit "y" when prompted. And yes, you are correct. If I run it again (flutter doctor) it prompts me like I never accepted the licenses.

@tvolkert
Copy link
Contributor

tvolkert commented Apr 2, 2018

@natem34 I wonder if we're not piping the stdin correctly under certain circumstances or something...

Can you reproduce this by manually running the sdkmanager?

C:\AndroidStudio\sdk\tools\bin\sdkmanager --licenses

If you run that yourself and accept all the licenses... then run it again... does it still prompt you to accept the licenses again? (and if not, does flutter stop complaining?)

@natem34
Copy link
Author

natem34 commented Apr 2, 2018

Okay, that brings up an interesting point... and I may have messed up the troubleshooting of this. When I browsed to the location for the sdkmanager, I then went to file (from windows explorer) and opened powershell as administrator (just running on autopilot). I went through the steps and accepted all the licenses, then (from the same powershell window) ran flutter doctor. All is well now. What I don't know is this. Did it work because I followed your step and went through the sdkmanager, or did it work because of the elevated powershell. I can't recall if I was using an administrator cmd prompt before... but I'd wager a guess I wasn't.

@tvolkert tvolkert changed the title Android licenses not accepted. To resolve this, run: flutter doctor --android-licenses Android/Windows: sdkmanager --licenses doesn't persist when run as non-administrator Apr 3, 2018
@tvolkert
Copy link
Contributor

tvolkert commented Apr 3, 2018

Chances are that you weren't using an administrator cmd prompt before, which meant that the process that the flutter tool spawned to run sdkmanager --licenses also wasn't running as administrator.

What's weird, though, is that the bug report you attached shows that the process acknowledged that you accepted all licenses and returned with a successful exit code, which can also be seen here:

So it would seem that when run as non-administrator, the sdkmanager command allows you to accept the licenses, but it doesn't record that acceptance, causing it to immediately think you still haven't accepted them?

In any case, I'm going to close this since you're no longer seeing it, so our ability to debug is diminished.

@tvolkert tvolkert closed this as completed Apr 3, 2018
@aitseps
Copy link

aitseps commented May 24, 2018

Hello friends, I would like to know if you could solve this problem, I am currently installing flutter, but when running flutter doctor generates the following:

Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel beta, v0.4.4, on Microsoft Windows [Versión 10.0.17134.48], locale es-CL)
[!] Android toolchain - develop for Android devices (Android SDK 27.0.3)
    X Android license status unknown.
[√] Android Studio (version 3.1)
[√] IntelliJ IDEA Ultimate Edition (version 2018.1)

I have followed your instructions in this discussion and I am detained in the following:

D:\Android Studio\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: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

D:\Android Studio\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: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

I would appreciate your comments.
@tvolkert

@shivamdwivedi1511
Copy link

shivamdwivedi1511 commented May 25, 2018

look every thing is fine you just need to set the JAVA_HOME variable with java jdk path

@sahil904
Copy link

sahil904 commented Sep 27, 2018

flutter doctor --android-licenses

this is the best solution for this issue

@stickyboiproject
Copy link

stickyboiproject commented Nov 5, 2018

untitled

can someone tell me whats wrong with my JAVA_HOME? i cant update my sdk because of this error message

C:\Users\Carlo-PC\AppData\Local\Android\Sdk\tools\bin>sdkmanager --update

ERROR: JAVA_HOME is set to an invalid directory: C:\Users\Carlo-PC\AppData\Local\Android\Sdk\tools\bin;

Please set the JAVA_HOME variable in your environment to match the
location of your Java installation.

@harshit0209
Copy link

Thanks! One more -- can you run the following and attach the generated bug report ZIP file here?

flutter doctor --bug-report --android-licenses

I search it every where but I found invalid replies. This is what worked well.

@mavmaso
Copy link

mavmaso commented Dec 31, 2019

PS C:\WINDOWS\system32> C:\Users\mavmaso\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

@iagofrota
Copy link

iagofrota commented Feb 29, 2020

My settings:
Windows 10 PRO
java version "1.8.0_241"
Java (TM) SE Runtime Environment (build 1.8.0_241-b07)
Java HotSpot (TM) 64-Bit Server VM (build 25.241-b07, mixed mode)

When I run the command flutter doctor, I get this message:

[√] Flutter (Channel stable, v1.12.13+hotfix.8, on Microsoft Windows [versão 10.0.18363.657], locale pt-BR)                               
[!] 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)                                                                                                           
    X Flutter plugin not installed; this adds Flutter specific functionality.                                                              
    X Dart plugin not installed; this adds Dart specific functionality.                                                                    
[√] VS Code, 64-bit edition (version 1.42.1)                                                                                               
[!] Connected device                                                                                                                       
    ! No devices available

When trying to run the command .\sdkmanager.bat with whatever options, I get this message:

Warning: Could not create settings
java.lang.IllegalArgumentException
        at com.android.sdklib.tool.sdkmanager.SdkManagerCliSettings.<init>(SdkManagerCliSettings.java:428)
        at com.android.sdklib.tool.sdkmanager.SdkManagerCliSettings.createSettings(SdkManagerCliSettings.java:152)
        at com.android.sdklib.tool.sdkmanager.SdkManagerCliSettings.createSettings(SdkManagerCliSettings.java:134)
        at com.android.sdklib.tool.sdkmanager.SdkManagerCli.main(SdkManagerCli.java:57)
        at com.android.sdklib.tool.sdkmanager.SdkManagerCli.main(SdkManagerCli.java:48)

bugreport_01
I don't understand why this is happening

@hanseld28
Copy link

@iagofrota
Tente rodar o comando .\sdkmanager.bat --licenses com a opção --sdk_root, especificando o caminho completo até a pasta bin da ferramenta.

Exemplo:
.\sdkmanager.bat --licenses --sdk_root=C:\android\tools\bin

@RewaNx7
Copy link

RewaNx7 commented Mar 20, 2021

flutter doctor --android-licenses

this is the best solution for this issue

thanks a lot it helped me!

@github-actions
Copy link

github-actions bot commented Aug 4, 2021

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 4, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
a: first hour The first hour of using Flutter platform-android Android applications specifically tool Affects the "flutter" command-line tool. See also t: labels.
Projects
None yet
Development

No branches or pull requests