540

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
  • 5,679
  • 3
  • 11
  • 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
  • Check here for Ionic 4 http://www.freakyjolly.com/resolved-failed-to-install-the-following-android-sdk-packages-as-some-licences-have-not-been-accepted/ – Code Spy May 27 '19 at 06:40
  • 26
    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
  • @SeymurMammadli your solution worked for me also. – Andrew Duncan Dec 02 '19 at 22:08
  • 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
  • 1
    Thanks @SeymurMammadli – Doilio Matsinhe May 18 '21 at 10:10

15 Answers15

926

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

amm0nium
  • 115
  • 1
  • 3
Hugo
  • 9,676
  • 2
  • 14
  • 9
  • 57
    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
  • 8
    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
  • great, working in OS el capitan – stackdave Jul 02 '17 at 11:29
  • 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` – guival Jul 25 '17 at 17:43
  • 12
    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
  • 6
    Hello, @BenjaminGruenbaum I am here once again after a year. – Shahid Karimi Dec 17 '17 at 23:43
  • Thank you. This worked for me also.. Thank you – Akash M Feb 13 '18 at 09:36
  • 9
    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
  • 1
    This answer should be marked as best answer – Long Nguyen Feb 28 '18 at 08:49
  • 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` – Erwin Rooijakkers 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
  • 1
    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
  • Works perfectly for me. – marco.broccio Mar 19 '19 at 12:04
  • 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
158

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,109
  • 8
  • 72
  • 95
124

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
  • 12,563
  • 6
  • 30
  • 50
Shailendra Yadav
  • 1,612
  • 1
  • 9
  • 13
  • 20
    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 Luk 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. – Tadej 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
  • Running `chmod -R 777 /usr/lib/android-sdk/` and accepting the license solved it on my Ubuntu – rajeman Mar 27 '21 at 03:06
69

I have resolve 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

WAS TESTED ON CORDOVA USING THE COMMAND:

cordova build android

-- UPDATE NEW FOLDER PATH --

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

Snow Bases
  • 1,688
  • 1
  • 16
  • 23
  • 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
63

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
  • 484
  • 6
  • 18
54

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,375
  • 1
  • 16
  • 27
Joe V.
  • 739
  • 6
  • 5
  • 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
33

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,400
  • 10
  • 17
23

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
  • 2,958
  • 2
  • 15
  • 29
  • 1
    bravo... very good answer. thankyou. worked for me on mac os catilina – Abhishek Garg Dec 26 '19 at 08:19
  • 1
    I have to login to vote for you. Very helpful. – chinhnguyen Mar 16 '20 at 03:15
  • 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
20

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
  • 18,827
  • 24
  • 140
  • 216
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
  • 570
  • 3
  • 10
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
  • 425
  • 1
  • 5
  • 7
12

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,475
  • 1
  • 16
  • 28
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
  • 911
  • 9
  • 12
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/
  • 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
-1

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
  • 1,845
  • 20
  • 17