616

I downloaded the latest Android SDK tools version 24.4.1. I used the command line to install SDKs. I typed y when asked

Do you accept the license 'android-sdk-license-c81a61d9' [y/n]: y after that install succeeded.

But when using Gradle 3.1 to build, the follows shows up

You have not accepted the license agreements of the following SDK components: [Android SDK Platform 23, Android SDK Build-Tools 23.0.1]. Before building your project, you need to accept the license agreements and complete the installation of the missing components using the Android Studio SDK Manager. Alternatively, to learn how to transfer the license agreements from one workstation to another, go to http://d.android.com/r/studio-ui/export-licenses.html

I checked ~/.android and /opt/android-sdk where Android tools are put. Neither contain folder named licenses.

codable
  • 6,439
  • 3
  • 15
  • 9
  • Please share your build.gradle file – Nishant Dubey Sep 29 '16 at 02:17
  • 1
    If on Windows, make sure to Run As Administrator – bland Aug 25 '18 at 16:23
  • 63
    I have solved the problem by going to the Android Studio-> Tools -> SDK manager and on SDK Tools I have installed Google Play Licensing Library Android SDK Tools Android SDK Platform Tools and the problem have been solved. – Seymur Mammadli Sep 18 '19 at 22:56
  • it's showing me this error: 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) – Ali Azaz Alam Oct 28 '20 at 09:05

15 Answers15

1012

The way to accept license agreements from the command line has changed. You can use the SDK manager which is located at: $ANDROID_SDK_ROOT/tools/bin

e.g on linux:

cd ~/Library/Android/sdk/tools/bin/

Run the sdkmanager as follows:

./sdkmanager --licenses

e.g on Windows:

cd /d "%ANDROID_SDK_ROOT%/tools/bin"

Run the sdkmanager as follows:

sdkmanager --licenses

And accept the licenses you did not accept yet (but need to).

For more details see the Android Studio documentation, although the current documentation is missing any description on the --licenses option.

Warning

You might have two Android SDKs on your machine. Make sure to check both ~/Library/Android/sdk and /usr/local/share/android-sdk! If unsure, fully uninstall Android Studio from your machine and start with a clean slate.

Update: ANDROID_HOME is deprecated, ANDROID_SDK_ROOT is now the correct variable

aetonsi
  • 208
  • 2
  • 9
Hugo
  • 10,546
  • 2
  • 17
  • 9
  • 66
    I accepted all licenses and got message: `Accept? (y/N): y All SDK package licenses accepted done` but error still appear. – saike Apr 04 '17 at 17:23
  • 9
    We found out we had two Android SDK's installed. One which was in use by Gradle and one managed by Android Studio. It might be you have the same issue. – Hugo Apr 05 '17 at 18:43
  • Hugo, where was that gradle one installed? – catbadger Jun 02 '17 at 12:46
  • This allowed me to accept packages, but it didn't solve the initial problem for some reason. By the way, in my case the command that listed the licenses was `sdkmanager --licenses` – gdvalderrama Jul 25 '17 at 17:43
  • 15
    All SDK package licenses accepted.======] 100% Computing updates... AND STILL DOES NOT WORK – Shahid Karimi Sep 26 '17 at 19:00
  • @ShahidKarimi what ended up being the issue? – Benjamin Gruenbaum Oct 16 '17 at 15:01
  • 1
    This should be marked as the answer, worked for me. – po10cySA Nov 10 '17 at 07:59
  • 7
    Hello, @BenjaminGruenbaum I am here once again after a year. – Shahid Karimi Dec 17 '17 at 23:43
  • 11
    For windows you have to go to C:\Users\shashank\AppData\Local\Android\Sdk\tools\bin, and run sdkmanager --licenses. and accept the licence which is not accepted. – Shashank Shah Feb 14 '18 at 12:23
  • for me, the following solution worked: i went to this path - C:\Users\\AppData\Local\Android\Sdk\tools\bin and ran these 2 commands in git bash: sdkmanager.bat --upgrade and sdkmanager.bat --licenses – Ashish Goyal Apr 24 '18 at 11:05
  • 2
    @saike I had to same error as you. What I figured out was I had two ANDROID_HOME set. Delete the duplicate and try again! – Joanne Jul 11 '18 at 06:11
  • 3
    `yes | sdkmanager --licenses > /dev/null` – Yarek T Jul 31 '18 at 11:54
  • @ShahidKarimi Run As Administrator on Windows – bland Aug 25 '18 at 16:22
  • 2
    `yes | sudo sdkmanager --licenses` – user2609980 Oct 21 '18 at 17:12
  • this dont work, when i run this it errors out as Error: Unknown argument --licenses – Raveen Beemsingh Dec 19 '18 at 05:13
  • i found this one out https://developer.android.com/studio/intro/update#download-with-gradle – Raveen Beemsingh Dec 19 '18 at 07:24
  • 2
    In Java 11 this will crash with NoClassDefFoundError. To work around this I had to modify `sdkmanager` by adding the following jars at the end of the `CLASSPATH` variable: `:$APP_HOME/lib/jaxb-core.jar:$APP_HOME/lib/jaxb-impl.jar:$APP_HOME/lib/jaxb-api.jar:$APP_HOME/lib/activation.jar`. All these jars can be downloaded from Oracle website. – Peter Dec 23 '18 at 22:28
  • I have no idea, or care what the licences were. but it seems to be working now with my ionic project. – vr_driver Feb 28 '19 at 13:15
  • This worked for me, although, on MacOSX the licenses are put in a folder outside this path. You'll need to move the licenses into the sdk directory. – Gus Mar 29 '19 at 15:54
  • In my case, the android sdk folder had two instances of sdkmanager: one in $ANDROID_HOME/bin/sdkmanager and another on $ANDROID_HOME/tools/bin/sdkmanager Had to run ./sdkmanager --licenses on both and the problem went away – Gubatron May 07 '19 at 02:47
  • This worked for android on MacOS as well. – hitautodestruct Jun 20 '19 at 05:25
  • It still didnt work until I reboot my windows PC. – Stanislav Mayorov Jul 14 '19 at 21:16
  • My problem was also that I had 2 versions of sdk, on Windows. After accepting the license in C:\Users\\AppData\Local\Android\Sdk\tools\bin, it still wasn't working. That's when I noticed my $ANDROID_HOME environment variable was pointing to the C:\Program Files\Android directory. I updated to the C:\Users\..., restarted my command prompt session, and everything worked. – jozolo Sep 26 '19 at 20:54
  • 1
    I've searched SO for over an hour to figure this out with no luck. On Windows 10 and absolutely none of the command line stuff has worked for me. Finally found a forum online that told me to: go to Tools -> SDK manager and just download another SDK and it'll prompt me to accept the license. – Justin Nov 19 '19 at 21:26
  • 1
    Am I the only one getting error: `Unknown argument --licenses`? I'm using Android SDK Tools 25.2.5 – Lumi Wang Nov 20 '19 at 13:17
  • @Hugo love you man, it solved my issue but I need to downgrade my jdk to 8 –  Nov 30 '19 at 09:45
  • Google has invalidated this answer. `sdkmanager --licenses` is no longer a thing. – Kevin Krumwiede Dec 18 '19 at 05:31
  • "sdkmanager --licenses" hasn't worked in a long time, need to use "sdkmanager --update" now which sucks when you're trying to use a very specific version. – Steazy Feb 28 '20 at 01:57
  • @saike You have to accept licence multiple times. You should press 'Y' multiple times – Satheeshkumar May 02 '20 at 07:39
  • This worked on a Mac – Chux May 07 '20 at 07:24
  • no sdkmanager on WSL Debian – elig May 29 '20 at 06:42
  • in my case path is C:\Users\os\AppData\Local\Android\Sdk\tools\bin>sdkmanager --licenses – Dinesh Gurjar Dec 18 '20 at 17:07
  • This no longer works in 2022 because the `tools` dir has been depreciated. Following the first answer here worked for me. https://stackoverflow.com/questions/68210100/java-lang-noclassdeffounderror-javax-xml-bind-annotation-xmlschema-when-accep – Sarah Kay Oct 26 '22 at 03:19
162

You can install and accept the license of the SDK & tools via 2 ways:

1. Open the Android SDK Manager GUI via command line

Open the Android SDK manager via the command line using:

# Android SDK Tools 25.2.3 and lower - Open the Android SDK GUI via the command line
cd ~/Library/Android/sdk/tools && ./android

# 'Android SDK Tools' 25.2.3 and higher - `sdkmanager` is located in android_sdk/tools/bin/.
cd ~/Library/Android/sdk/tools/bin && ./sdkmanager

View more details on the new sdkmanager.

Select and install the required tools. (your location may be different)

2. Install and accept android license via command line:

Update the packages via command line, you'll be presented with the terms and conditions which you'll need to accept.

- Install or update to the latest version

This will install the latest platform-tools at the time you run it.

# Android SDK Tools 25.2.3 and lower. Install the latest `platform-tools` for android-25
android update sdk --no-ui --all --filter platform-tools,android-25,extra-android-m2repository

# Android SDK Tools 25.2.3 and higher
sdkmanager --update

- Install a specific version (25.0.1, 24.0.1, 23.0.1)

You can also install a specific version like so:

# Build Tools 23.0.1, 24.0.1, 25.0.1
android update sdk --no-ui --all --filter build-tools-25.0.1,android-25,extra-android-m2repository
android update sdk --no-ui --all --filter build-tools-24.0.1,android-24,extra-android-m2repository
android update sdk --no-ui --all --filter build-tools-23.0.1,android-23,extra-android-m2repository
# Alter the versions as required                      ↑               ↑

# -u --no-ui  : Updates from command-line (does not display the GUI)
# -a --all    : Includes all packages (such as obsolete and non-dependent ones.)
# -t --filter : A filter that limits the update to the specified types of
#               packages in the form of a comma-separated list of
#               [platform, system-image, tool, platform-tool, doc, sample,
#               source]. This also accepts the identifiers returned by
#               'list sdk --extended'.

# List version and description of other available SDKs and tools
android list sdk --extended
sdkmanager --list
Anil
  • 21,730
  • 9
  • 73
  • 100
  • Thank you very much, I don't know why but using this command worked like a charm and the licence is accepted. I just replaced version 25.0.1 by 25.0.2 for latest version ;) – A. Muller Mar 28 '17 at 09:37
  • 47
    `./sdkmanager --update` triggered the agreement for me. – earthmeLon Apr 08 '17 at 22:05
  • I dont have a Library folder for my user... – Radmation Oct 24 '17 at 03:59
  • 1
    Did not trigger the agreement for me – Petr Gazarov Jul 06 '18 at 00:07
  • 26
    I just get Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema when I run ./sdkmanager --licenses :( - any ideas? – Roman Gaufman Aug 29 '18 at 16:51
  • Couldn't find the required build tools in the GUI sdk manager. Command line worked like a charm! – Kaushik Wavhal Apr 06 '19 at 19:56
  • 4
    @RomanGaufman You ever find a solution to your comment, I am running into the same issue? – james emanon Jun 05 '19 at 06:15
  • 2
    Same issue for me as @RomanGaufman – paul_f Nov 22 '19 at 17:23
  • @RomanGaufman What helped for me was to install Java 8 and have JAVA_HOME point to it. According to [this](https://stackoverflow.com/a/51644855/665780) you can also do `set JAVA_OPTS=-XX:+IgnoreUnrecognizedVMOptions --add-modules java.xml.bind` prior to executing sdkmanager, but this did not work for me – Dennie May 13 '21 at 17:52
  • 6
    @jamesemanon I solved this issue: 1) open android studio. 2) Go to Preferences -> Appearance & Behavior -> System settings -> Android SDK. 3) Click on the SDK tools tab. 4) Search for Android SDK command-line tools and install them. – tn2000 May 19 '21 at 20:22
135

Go to your $ANDROID_HOME/tools/bin and fire the cmd

./sdkmanager --licenses

Accept All licenses listed there.

After this just go to the licenses folder in sdk and check that it's having these five files:

android-sdk-license, android-googletv-license, android-sdk-preview-license, google-gdk-license, mips-android-sysimage-license

Give a retry and build again, still jenkins giving 'licenses not accepted' then you have to give full permission to your 'sdk' directory and all it's parent directories. Here is the command:

sudo chmod -R 777 /opt/

If you having sdk in /opt/ directory.

Nagaraj S
  • 13,316
  • 6
  • 32
  • 53
Shailendra Yadav
  • 1,822
  • 1
  • 12
  • 16
  • 21
    In case of windows path would be like - `C:\Users\xxx\AppData\Local\Android\Sdk\tools\bin`, and command `sdkmanager --licenses``./` not needed for windows. – garg10may Nov 15 '17 at 11:01
  • thanks @garg10may running `./sdkmanager --licenses` in powershell worked perfectly for all the SDKs I installed via Android Studio which I only installed to use Phonegap CLI - I dont have any Android Studio projects – vahanpwns Feb 02 '18 at 11:47
  • @garg10may i am not having bin folder under tools folder on windows10 what should i do ? – Heemanshu Bhalla Feb 08 '18 at 19:14
  • I tried `sudo chmod -R 775 /opt/` and it didn't work, with `777` everything worked ok, thanks! – Jorge Vargas Mar 19 '18 at 23:44
  • I have been struggling with this problem for days and `sudo chmod -R 777 /opt/` finally fixed it. Thanks! – Duncan Lukkenaer Apr 24 '18 at 08:54
  • On Windows 10 opening cmd with administrator privileges and then typing cd C:\Program Files (x86)\Android\android-sdk\tools\bin\ and then sdkmanager --update worked for me. After that I just had to press "y" twice in order to accept the licenses. – tedi Nov 29 '18 at 14:19
  • 1
    licenses folder is missing , what to do ? – Prince Hamza Mar 16 '19 at 05:39
  • The solution will also work in React Native https://aboutreact.com/you-have-not-accepted-the-license-agreements-of-the-following-sdk-components/ – snehal agrawal Nov 19 '19 at 18:35
  • I'm on Windows and there is no `tools` folder in `/Android/Sdk/`. – mneumann Apr 15 '20 at 17:36
  • NEVER do this """ sudo chmod -R 777 /opt/""" You could break so many programs . Try to find a better solution . – LUser Mar 02 '21 at 10:07
  • 1
    Running `chmod -R 777 /usr/lib/android-sdk/` and accepting the license solved it on my Ubuntu – DevD'Silva Mar 27 '21 at 03:06
  • 1
    You'll need JAVA 8. Don't use newer versions of Java. – Jefferson Dec 27 '21 at 21:24
  • Thanks for the hint @Jefferson, I was getting a ClassNotFoundException when trying with a newer java version, changing my JAVA_HOME to the jdk8 home (temporarily) did it. – cleberz Jan 25 '22 at 01:25
97

I have resolved the problem by using the command:

  1. Go to: C:\Users\ [PC NAME] \AppData\Local\Android\sdk\tools\bin\ (If the folder is not available then download the Android SDK first, or you can install it from the android studio installation process.)
  2. Shift+Left click and Press W, then Enter to open CMD on the folder path
  3. Type in the cmd: sdkmanager --licenses
  4. Once press enter, you need to accept all the licenses by pressing y

Checking the licenses

  1. Go to: C:\Users\ [PC NAME] \AppData\Local\Android\sdk\
  2. Check the folder named licenses
android-googletv-license
android-sdk-license
android-sdk-preview-license
google-gdk-license
intel-android-extra-license
mips-android-sysimage-license

AS NEW UPDATE FOLDER PATH (Current Android Studio)

Open Android Studio, Tools > Sdk Manager > Android SDK Command-Line Tools (Just Opt-in)

enter image description here

SDKManager will be store in :

  1. Go to C:\Users\ [PC NAME] \AppData\Local\Android\Sdk\cmdline-tools\latest\bin
  2. Type in the cmd: sdkmanager --licenses

Documentation to using the Android SDK: https://developer.android.com/studio/command-line/sdkmanager.html

Snowbases
  • 2,316
  • 2
  • 20
  • 26
  • 3
    Thank you!!! Using the sdk-manager available after following your install directions and path you suggested above (I use Arch Linux so --> `/home/[USER]/Android/Sdk/cmdline-tools/latest/bin/sdkmanager`) allowed me to get past the licenses issue! The `sdkmanager` installed by Android SDK here `/opt/android-sdk/tools/bin/sdkmanager` seems to be broken. – Efosa Mar 09 '20 at 08:01
  • 3
    not windows, but `ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.` – Michael Jan 31 '21 at 18:12
  • 1
    that JAVA_HOME is a separate error. Download JDK 11 (preferably 11) - https://jdk.java.net/archive/ -> extract -> create new path in environment variables and add the directory as JAVA_HOME – Liban Jul 11 '23 at 05:44
65

For Windows users w/o using Andoid Studio:

  1. Go to the location of your sdkmanager.bat file. Per default it is at Android\sdk\tools\bin inside the %LOCALAPPDATA% folder.

  2. Open a terminal window there by typing cmd into the title bar

  3. Type

    sdkmanager.bat --licenses
    
  4. Accept all licenses with 'y'

TheInitializer
  • 566
  • 7
  • 20
  • 1
    I found this in Program Files, and it didn't maintain accepting of licenses until I ran As Administrator – bland Aug 25 '18 at 16:21
  • 4
    One thing to note here if you're from the UK, spelling, make sure you spell `licenses` the US way, not `licences` as we would in the uk - simple mistake that had me stumped for a minute, not seeing wood for trees – StudioTime Dec 01 '18 at 13:42
  • If you have this error in Unity as I did. Restart it after accepting licenses. – Dmitry Bosikov Aug 28 '19 at 03:41
57

Update for macOS Sierra 10.12.6 - Android Studio for Mac 2.3.3

Locate the sdkmanager file usually under:

/Users/YOUR_MAC_USER/Library/Android/sdk/tools/bin

./sdkmanager --licenses

Warning: File /Users/mtro.josevaler**strong text**io/.android/repositories.cfg could not be loaded. 6 of 6 SDK package licenses not accepted. Review licenses that have not been accepted (y/N)? Y

To validate the problem has gone just repeat the operation involved in the license issue.

DragonKnight
  • 1,740
  • 2
  • 22
  • 35
Joe V.
  • 769
  • 6
  • 5
  • 1
    I'm not able to locate 'tools' folder presend in Android/sdk directory... Did thorough walk throw but didn't find it. Wokring on Mac OS Mojave 10.14.4 and Android Studio 3.6.3. Can help? – Jayprakash Dubey Apr 26 '20 at 11:42
38

I solved the problem by opening the Android SDK Manager and installing the SDK build tools for the version it is complaining about (API 24).

I had also updated using the command line previously and I suspect the Android SDK Manager has a more complete way of resolving dependencies, including the license.

Tšeliso Molukanele
  • 1,630
  • 12
  • 18
29

Maybe I'm late, but this helped me accept SDK licenses for OSX,

If you have android SDK tools installed, run the following command

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

Accept all licenses by pressing y

Voila! You have accepted SDK licenses and are good to go..

Gowtham
  • 3,198
  • 2
  • 19
  • 30
  • 1
    On macOS you can use `yes | ~/Library/Android/sdk/tools/bin/sdkmanager --licenses` to automatically accept them all, on Linux use `y | ~/Library/Android/sdk/tools/bin/sdkmanager --licenses`. `y` is basically the same as `yes`, it just outputs `y` to accept until there is no more input requested and the process stops. – dragon788 Mar 09 '21 at 19:34
21

If you want to use the IDE to accept the license, I also found it easy to open up Android Studio and create a new basic project to trigger the license agreements. Once I created a project, the following licensing dialog was presented that I needed to agree to:

enter image description here

I documented fully the information in the following post: Accepting the Android SDK License via Android Studio

atconway
  • 20,624
  • 30
  • 159
  • 229
15

I had a similiar problem but ./sdkmanager --licenses didnt work. I follow this thread and "obladors" comment gave me the solution: https://github.com/oblador/react-native-vector-icons/issues/527

What eventually solved my problem was: Running ./sdkmanager "build-tools;23.0.1"

Change 23.0.1 with your version

Luis Gurmendez
  • 654
  • 4
  • 10
14

You can accept the license agreement by launching Android Studio, then going to:

Help > Check for Updates...

When you are installing updates, it'll ask you to accept the license agreement. Accept the license agreement and install the updates, and you are all set.

Gregory R.
  • 1,815
  • 1
  • 20
  • 32
  • 1
    Excellent Gregory R. I tried it in the command line and a few other ways and this one was the only on that worked. – mediaguru Jan 29 '18 at 03:28
13

I ran across this error when i ran cordova build android

I solved this issue by firing ./sdkmanager --licenses and accepting all the licenses.

  1. You have a sdkmanager.bat under the android sdk folder in the path: android/sdk/tools/bin
  2. To trigger that open a command prompt in android/sdk/tools/bin
  3. type ./sdkmanager --licenses and enter
  4. Press y to review all licenses and then press y to accept all licenses
Z.T
  • 485
  • 1
  • 5
  • 8
8

In linux

 1. Open a terminal
 2. Write: "cd $ANDROID_HOME/tools/bin (this path can be /home/your-user/Android/Sdk/tools/bin)"
 3. Write: "./sdkmanager --licenses"
 4. To accept All licenses listed, write: "y"
 5. Ready!

If your are building an app with Ionic Framework, just write again the command to build it.

Carlos Espinoza
  • 1,115
  • 11
  • 13
1

If you are having this problem for a React Native app, in addition to above mentioned steps, make sure you have the local.properties file in the android directory(AppName/android) of your app which points to your 'sdk' directory:

sdk.dir=/PATH_TO_SDK/
Nauman Tahir
  • 466
  • 6
  • 11
  • For me android app this also was the issue.. Other than executing ``` yes | sdkmanager --licenses && sdkmanager --update```. You need to set the local.properties correctly eg: *sdk.dir=~/Library/Android/sdk*. In my case I was giving the wrong pas in ~/Library/Android/sdk/platforms/android-30 – nantitv May 18 '21 at 15:42
0

I have resolved the issue by below steps:

  1. update the android sdk with command "tools/android update sdk --no-ui"
  2. got to android sdk folder on jenkins machines, create "licenses" folder
  3. created file named "android-sdk-license" and paste the license from dev machine
Vaseem007
  • 2,401
  • 22
  • 20