"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


You need to accept the licences before building.

According to Android SDK docs you can use the following command depending on the sdkmanager location: Docs on --licenses option seems to be missing though.

yes | sdkmanager --licenses

GNU/Linux Distributions:

yes | ~/Android/Sdk/tools/bin/sdkmanager --licenses

macOS:

export JAVA_HOME=/Applications/Android\ Studio.app/Contents/jre/jdk/Contents/Home
yes | ~/Library/Android/sdk/tools/bin/sdkmanager --licenses

Windows:

%ANDROID_HOME%/tools/bin/sdkmanager --licenses

Flutter:

> flutter doctor --android-licenses

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


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


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

flutter doctor --android-licenses

Problem: SDK license not accepted

enter image description here

Step 1: Open SDK Manager

After opening the SDK manager, open the SDK tools tab as shown below

enter image description here

Step 2: Check the option Show Package Details

It'll list out all the versions of SDK tools

enter image description here

Step 3: Install the required SDK tool version

Check the specific version of SDK tools that is complaining (for me, it was 29.0.3 as shown above in the first screenshot) from the list, accept the agreement in the dialog that opens next and you're done.