[android] "Failed to install the following Android SDK packages as some licences have not been accepted" error

I am getting this error in jitpack, I've tried everything on the internet. Below is my error

Failed to install the following Android SDK packages as some licences have not been accepted.
     platforms;android-26 Android SDK Platform 26
     build-tools;28.0.3 Android SDK Build-Tools 28.0.3
  To build this project, accept the SDK license agreements and install the missing components using the Android Studio SDK Manager.

And when i run ./sdkmanager --licenses

 All SDK package licenses accepted.======] 100% Computing updates...             

Using sudo with the above command gives

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

additional error log

File /opt/android-sdk-linux/.android/repositories.cfg could not be loaded.
Checking the license for package Android SDK Build-Tools 28.0.3 in /opt/android-sdk-linux/licenses
Warning: License for package Android SDK Build-Tools 28.0.3 not accepted.
Checking the license for package Android SDK Platform 26 in /opt/android-sdk-linux/licenses
Warning: License for package Android SDK Platform 26 not accepted.

I don't know why it's checking for licenses there when my sdk location is other

This question is related to android android-studio android-sdk-tools

The answer is


On Windows:

  1. Add USER Environment variables:

NOTE: Path should be appended

JAVA_HOME           %ProgramFiles%\Android\Android Studio\jre
ANDROID_SDK_ROOT    %LocalAppData%\Android\Sdk
Path                %LocalAppData%\Android\Sdk
  1. Run the below command to accept licenses:

NOTE: Accept all licenses (say y)

%ANDROID_SDK_ROOT%/tools/bin/sdkmanager.bat --licenses
  1. Now run your app:

(like below, or another command that failed for you):

cd \myapp\
react-native run-android

I tried many solutions but didn't work for me. The below solution works for me.

locate the sdkmanager file in android SDK.

In my case : ~/Android/Sdk/tools/bin

go to that path : cd ~/Android/Sdk/tools/bin

Accept licenses manually : ./sdkmanager --licenses Enter Yes or y


In my case updating buildToolsVersion in app level build.gradle worked perfectly. If you don't know which to use you can create new project and copy buildToolsVersion from that into existing one.


Tried this on Android Studio and it worked for me:

Tools > SDK Manager (Make sure to check Show Packages below)

SDK Platforms > Show Packages > Android - 28 SDK Platforms > Show Packages > Android - 28

SDK Tools > Show Packages > 28.0.3 SDK Tools > Show Packages > 28.0.3


If you are working with Flutter then this command would definitely work for you.

flutter doctor --android-licenses

This works for me in Windows 10:

C:
cd \Users\YOUR_USER\AppData\Local\Android\Sdk\cmdline-tools\latest\bin
sdkmanager.bat --licenses

After, yes to all


In Android Studio go to Tools -> SDK Manager.

Go to SDK Tools tab.

Select the Android SDK Command-line Tools (latest) and download by pressing Apply.

enter image description here

On Windows, you can find the sdkmanager.bat at

C:\Users\[your_user]\AppData\Local\Android\Sdk\cmdline-tools\latest\bin

enter image description here


Appears to be a bug at the momment: https://issuetracker.google.com/issues/123054726

Solution that worked for me:

Create a .travis.yml file in your project directory and copy these lines:

before_script:
- mkdir "$ANDROID_HOME/licenses" || true
- echo "24333f8a63b6825ea9c5514f83c2829b004d1fee" > "$ANDROID_HOME/licenses/android-sdk-license"

Reference: https://github.com/square/RxIdler/pull/18/files


This works for me:

yes | ./sdkmanager "platforms;android-28"

yes | ./sdkmanager "build-tools;28.0.3"

yes | ./sdkmanager --licenses


If you are getting this error while using Flutter then please run the below command on command prompt.

flutter doctor --android-licenses

If you get below error after running the above command

Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema
    at com.android.repository.api.SchemaModule$SchemaModuleVersion.<init>(SchemaModule.java:156)
    at com.android.repository.api.SchemaModule.<init>(SchemaModule.java:75)
    at com.android.sdklib.repository.AndroidSdkHandler.<clinit>(AndroidSdkHandler.java:81)
    at com.android.sdklib.tool.sdkmanager.SdkManagerCli.main(SdkManagerCli.java:73)
    at com.android.sdklib.tool.sdkmanager.SdkManagerCli.main(SdkManagerCli.java:48)

Then please do the below steps

  1. Open android studio
  2. Go to SDK manager
  3. Click on SDK tools tab
  4. Install Android SDK command line tool
  5. Run flutter doctor --android-licenses again

in Windows OS go to your sdkmanager path directory in cmd

You can find your sdkmanager in C:\Users\USER\AppData\Local\Android\Sdk\tools\bin

then execute the followwing command:

sdkmanager --licenses

after that it will ask to accept license agreement several times then accept all by just typing y on cmd


in Windows OS go to your sdkmanager path then execute

./sdkmanager.bat --licenses

You can find your sdkmanager in C:\Users\USER\AppData\Local\Android\Sdk\tools\bin

To find your actual android SDK path follow the red marked area of the below picture

enter image description here


use android-28 with build-tools at version 28.0.3; or build-tools at version 26.0.3.

or try this: yes | sudo sdkmanager --licenses


You can accept the license agreements of the stated SDKs by going to the SDK Manager (Settings > [Search for Android SDK]) then find the packages noted in the error message and find them there. Chances are, you'll find SDKs that are not fully installed and installing them will ask you to accept the license agreement. enter image description here


MacOS Catalina

Step 1: Changing Android Studio Preference

  1. Open-up your Android Studio
  2. Press Command+, or go to top-left AppBar Android Studio > Preferences.
  3. From Left Pane, select Appearance > System Settings > Android SDK
  4. Select SDK Tools next to SDK Platforms and under Android SDK Location
  5. Check mark Android SDK Command-line Tools (latest) and Press OK button.
  6. Wait for installation to be finished

Locating Preferences of Android Studio

Android Studio Preferences

Step 2 (For Flutter Users):

  1. Go to Terminal and run the following command

flutter doctor --android-licenses

Step 2 (For Android Users):

  1. Go to the Terminal and run the following command

export JAVA_HOME=/Applications/Android\ Studio.app/Contents/jre/jdk/Contents/Home

yes | ~/Library/Android/sdk/tools/bin/sdkmanager --licenses


To add to the answers, you can also change to the sdkmanager directory and in a sub shell and accept the licenses there

(
    cd /home/user/android-sdk-linux/tools/bin
    yes | ./sdkmanager --licenses
)

If you are using flutter go with the following steps

1.open the command prompt

Then the following command

2.C:\Users\niroshan>flutter doctor

And you will see the issues as follows

Doctor summary (to see all details, run flutter doctor -v):
[v] Flutter (Channel stable, 1.22.2, on Microsoft Windows [Version 10.0.17763.1339], locale en-US)

[!] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
    X Android licenses not accepted.  To resolve this, run: flutter doctor --android-licenses
[!] Android Studio (version 4.1.0)
    X Flutter plugin not installed; this adds Flutter specific functionality.
    X Dart plugin not installed; this adds Dart specific functionality.
[v] VS Code (version 1.50.1)
[!] Connected device
    ! No devices available

! Doctor found issues in 3 categories.

Actually what you have to run is the below command

C:\Users\niroshan>flutter doctor --android-licenses

https://www.youtube.com/watch?v=g789PvvW4qo really helped me. What had done is open SDK Manager and download any new SDK Platform (dont worry it wont affect your desired api level).

Because with downlaoding any SDK Platforms(API level), you should accept licences. That's the trick worked for me.


I just done File -> Invalidate caches and restart Then install missing packages. Worked for me.


On Mac OS 10.15.1, I got the same error even after accepted all the licenses by running sdkmanager --licenses It worked after I updated the ANDROID_HOME path configuration in the ~/.bash_profile to the following

export ANDROID_HOME=/Users/your_username/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
export PATH=$PATH:~/Library/Android/sdk/platform-tools

And reload the ~/.bash_profile

source ~/.bash_profile 

in my case I just installed a new version of android studio on a new laptop and cloned the old repository where buildToolsVersion "30.0.2" at application level build.gradle. I just upgraded to 30.0.3 which android studio recommended on its own and the problem went away


Examples related to android

Under what circumstances can I call findViewById with an Options Menu / Action Bar item? How to implement a simple scenario the OO way My eclipse won't open, i download the bundle pack it keeps saying error log getting " (1) no such column: _id10 " error java doesn't run if structure inside of onclick listener Cannot retrieve string(s) from preferences (settings) strange error in my Animation Drawable how to put image in a bundle and pass it to another activity FragmentActivity to Fragment A failure occurred while executing com.android.build.gradle.internal.tasks

Examples related to android-studio

A failure occurred while executing com.android.build.gradle.internal.tasks "Failed to install the following Android SDK packages as some licences have not been accepted" error Android Gradle 5.0 Update:Cause: org.jetbrains.plugins.gradle.tooling.util This version of Android Studio cannot open this project, please retry with Android Studio 3.4 or newer WARNING: API 'variant.getJavaCompile()' is obsolete and has been replaced with 'variant.getJavaCompileProvider()' Flutter plugin not installed error;. When running flutter doctor ADB.exe is obsolete and has serious performance problems Android design support library for API 28 (P) not working Flutter command not found How to find the path of Flutter SDK

Examples related to android-sdk-tools

"Failed to install the following Android SDK packages as some licences have not been accepted" error Flutter does not find android sdk Failed to run sdkmanager --list with Java 9 You have not accepted the license agreements of the following SDK components Automatically accept all SDK licences Android SDK location should not contain whitespace, as this cause problems with NDK tools Finding Android SDK on Mac and adding to PATH Android SDK folder taking a lot of disk space. Do we need to keep all of the System Images? Daemon not running. Starting it now on port 5037 libz.so.1: cannot open shared object file