124

I'm getting the following error when trying to install an android platform on a Cordova project. I've been following this guide: https://cordova.apache.org/docs/en/latest/guide/cli/

Error occurs when executing the following: $ cordova platform add android --save

A problem occurred configuring root project 'android'. You have not accepted the license agreements of the following SDK components: [Android SDK Platform 24].

I've searched all over for ways to accept the license agreement of Android SDK Platform 24, but no real luck.

Thank you ahead of time.

Daneye
  • 1,278
  • 2
  • 9
  • 8
  • 1
    for windows, Open SDK Manager with Administrator access. Deselect all, Find SDK Platform 24, check that, install. There you can accept the license. – Nick Chan Abdullah Jun 23 '17 at 06:17
  • 1
    for me the problem was having installed `android-sdk` from multiple places (`brew`, `brew cask` and `android-studio`) and not calling the appropriate `sdkmanager --licenses` command – Pierre-Alexis de Solminihac Oct 27 '17 at 17:19
  • Possible duplicate of [Automatically accept all SDK licences](https://stackoverflow.com/questions/38096225/automatically-accept-all-sdk-licences) – user202729 Feb 19 '19 at 11:56

33 Answers33

172

You can also just execute

$ANDROID_HOME/tools/bin/sdkmanager --licenses

Or for Windows execute

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

-- OR --

C:\Users{your-username}\AppData\Local\Android\sdk\tools\bin\sdkmanager --licenses

(credit for windows command to @puneet-kumar)

bunny
  • 1,316
  • 2
  • 13
  • 22
Hardik Patel
  • 3,868
  • 1
  • 23
  • 37
166

I'm not exactly sure how cordova works, but once the licenses are accepted it creates a file. You could create that file manually. It is described on this question, but here's the commands to create the required license file.

Linux:

mkdir "$ANDROID_HOME/licenses"
echo -e "\n8933bad161af4178b1185d1a37fbf41ea5269c55" > "$ANDROID_HOME/licenses/android-sdk-license"

Windows:

mkdir "%ANDROID_HOME%\licenses"
echo |set /p="8933bad161af4178b1185d1a37fbf41ea5269c55" > "%ANDROID_HOME%\licenses\android-sdk-license"
Community
  • 1
  • 1
Mike
  • 5,482
  • 2
  • 21
  • 25
  • Hey Mike, from what directory what I execute those commands? Thanks! – Daneye Nov 02 '16 at 15:38
  • Working directory shouldn't matter, as long as the $ANDROID_SDK environment variable is defined. This may also be $ANDROID_HOME. One of those should be defined; It is the location of the android SDK. You can type 'printenv' and search through the defined variables to find it. Or just 'echo $ANDROID_HOME' to see if it's set. This is assuming linux... windows you would reference the environment variables by %ANDROID_SDK% instead of $ANDROID_SDK. – Mike Nov 02 '16 at 17:29
  • 5
    Along with the error Cordova will echo the path to ANDROID_HOME (in case you can't find it)! If ANDROID_HOME is not set you can set it manually like this `set ANDROID_HOME="C:\Users\*YOUR_USER_NAME*\AppData\Local\Android\sdk"` and the execute the above commands. – Arno van Oordt Nov 02 '16 at 19:59
  • Using Android Studio and installing Android version 24 fixed this issue for me. – David Douglas Nov 17 '16 at 11:54
  • 3
    Despite sdk build tools 24 installed. my issue was not resolved on mac machine. Solved this by manually creating licences folder and file android-sdk-license as explained above – HalfWebDev Nov 27 '16 at 12:32
  • I also tried installing from the SDK manager and it did not resolve the issue. Mike's solution did. – CarbonMan Dec 04 '16 at 21:59
  • Works great. One thing I noticed is that I apparently have 2 different versions of the SDK on my machine, so when I'd accept the license of one, my ANDROID_HOME was the other. So this fixes it, but the problem is a bit deeper and needs to be fixed, too. – Gant Laborde Mar 24 '17 at 13:15
  • Looks like another UID is needed for platform and build-tools: `d56f5187479451eabf01fb78af6dfcb131a6481e`. `8933bad161af4178b1185d1a37fbf41ea5269c55` still works for Google Repository and Android Support Repository. – Paul Oct 11 '17 at 21:29
  • I've tried everything, but for me it is still not working. – Giovanni Oct 20 '17 at 10:21
  • I get permission denied (even with sudo). If I try to execute the command with `sudo su`, then it says >file or directory not found. – PlayHardGoPro Apr 18 '18 at 17:35
  • Strange, I suppose you don't have write permission to the directory. Try "sudo chmod -R 777 %ANDROID_HOME%\licenses" – Mike Apr 19 '18 at 14:24
  • @Mike its showing me: mkdir: cannot create directory ‘/licenses’: Permission denied – Niladri Banerjee - Uttarpara Jul 20 '18 at 05:17
  • open cmd as administrator – Ahsan Ahmed Mar 20 '20 at 06:04
58

I had this problem on Mac OS X 10.12.1 with Cordova 6.4.0 and Android Studio 2.2.3.

When I installed Android Studio it installed Platform 25, but not 24. To install 24:

  • Open Android Studio.
  • Open Android Studio Menu > Preferences.
  • Appearance & Behavior > System Settings > Android SDK
  • Tick the box for Android 7.0 (Nougat) | 24
  • Click ok and follow the instructions.
jxmallett
  • 4,087
  • 1
  • 28
  • 35
  • Note: don't forget to adjust android version to SDK platform missing – Hugo H Jul 16 '17 at 08:53
  • 2
    I did this, but I probably could've saved a bit of time by clicking "Show Package Details" and selecting only the SDK, rather than installing Google APIs and Source as well. – Aaron Jul 18 '17 at 21:42
  • Weeks has passed since my last build. re-building my app again I experienced the same issue above but solves it after doing this solution. – Jur P May 13 '18 at 12:54
31

The simplest way to solve this issue is to accept the licenses using the following command:

Windows OS:

C:\Users\{your-username}\AppData\Local\Android\sdk\tools\bin\sdkmanager --licenses

You will be presented with disclaimers. In order to continue your development efforts, you need to answer 'y' to all disclaimers.

Full Array
  • 769
  • 7
  • 12
27

I had exactly the same problem. Then i installed "Android 7.0 (API 24) > SDK Platform" and it worked.

enter image description here

Feyyaz
  • 561
  • 1
  • 5
  • 12
27

Go to Android\sdk\tools\bin

None of the above solutions worked for me and finally this single line accepted all android licences.

yes | sdkmanager --licenses && sdkmanager --update
Shark Lasers
  • 441
  • 6
  • 15
vishwaraj
  • 487
  • 5
  • 5
  • 1
    If `windows` users are getting an error. Try `sdkmanager --licenses && sdkmanager --update` and accept the licenses manually. – Rahmat Ali Jan 23 '20 at 14:15
  • For macOs user go to **/Users/USERNAME/Library/Android/sdk/tools/bin** and ```yes | ./sdkmanager --licenses```. and ./sdkmanager --help to know more. – Pushpak Sharma Feb 10 '20 at 17:14
17

In my case I don't use the Android studio (I am using eclipse). I did the following step: Solved just by running the command

android-sdks/tools/bin$ ./sdkmanager --update

Which created a licenses directory and added a file called android-sdk-license inside it.

Then you can run (licenses option is not available unless you did the step above)

android-sdks/tools/bin$ ./sdkmanager --licenses

and accept the license (however, in my case I didn't need to do that)

BeeZone
  • 171
  • 1
  • 5
13

I had the issue. You do not need to copy or to create any folder, just be careful of your SDK path. It must be the same of the environnement variable (ANDROID_HOME), which wasn't the same for me. I don't know why.

sdk location

peterh
  • 11,875
  • 18
  • 85
  • 108
John
  • 737
  • 5
  • 13
9

I installed android sdk build-tools 24(it's current version 24.0.3) through SDK manager. Path to open SDK manager is shown in img file attached. This solved my problem SDK Manager

BruS
  • 99
  • 2
  • 1
    I don't see an attached image, but this worked for me too. There's a button in Android Studio for SDK Manager, and then you can open a standalone SDK manager which will let you pretty easily download all the android 24 stuff – Yonatan Kogan Nov 21 '16 at 15:21
  • Again I faced same issue when installing using cordova build in another pc with windows 7 os. This time I had build tools 24 already installed. So followed steps mentioned by Feyyaz below. That is installing Android 7.0 (API 24) and worked. So I feel latest cordova greater than 6 version needs API 24 with build tool 24 or higher version. But I didn't found any documentation for this on their website. – BruS Dec 07 '16 at 15:04
  • on MacOS and Linux the SDK manager is at $ANDROID_HOME/tools/android – Tony Laidig Dec 23 '16 at 16:39
7

I had the Android SDK by installing the Android Studio and got this error too. There's a simple solution from the user guide.

  1. On a machine with Android Studio installed, click Tools > Android > SDK Manager. At the top of the window, note the Android SDK Location.

  2. Navigate to that directory and locate the licenses/ directory inside it.

    (If you do not see a licenses/ directory, return to Android Studio and update your SDK tools, making sure to accept the license agreements. When you return to the Android SDK home directory, you should now see the directory.)

  3. Copy the entire licenses/ directory and paste it into the Android SDK home directory on the machine where you wish to build your projects.

Community
  • 1
  • 1
JavaNoScript
  • 2,345
  • 21
  • 27
7

This error can come if the system is not picking up the ANDROID_HOME environmental variable from the proper path. Make sure you have installed the Android SDK and have set the ANDROID_HOME variable properly to the appropriate path as in the below image:

ANDROID_HOME_PATH

If the ANDROID_HOME variable is not defined, the system tries to pick the path from a default path(this might not be the path where the Android SDK is defined, leading to this issue).

6

Prerequisites

Answer

  • Go to C:\Users\{user}\AppData\Local\Android\sdk\tools\bin (Your android SDK Tools folder)

  • Run sdkmanager --licenses

  • It'll ask you to accept whatever the agreements remaining to be accepted. you'll just have to type "y" and enter.

  • Will solve the issue

Ruben Szekér
  • 1,065
  • 1
  • 10
  • 21
Lakshitha Ruwan
  • 949
  • 1
  • 9
  • 12
  • Tthis is also great if you have a build server that has to auto download sdk's. – Roel Sep 27 '17 at 07:30
  • I Tried that and I get `Couldn't load neither find main class com.android.sdklib.tool.SdkManagerCli`. Ideas? – PlayHardGoPro Apr 18 '18 at 19:20
  • This might be helpful https://stackoverflow.com/questions/40718487/error-could-not-find-or-load-main-class-com-android-uiautomator-uiautomatorview/40843059#40843059. you can try run './SdkManagerCli' inside /sdklib/tools folder. – Lakshitha Ruwan Apr 19 '18 at 05:01
5

Install the following component:

enter image description here

Sumant Singh
  • 904
  • 1
  • 14
  • 16
5

I am using Mac and I resolved it using this command:

$ which sdkmanager
/usr/local/bin/sdkmanager
$ /usr/local/bin/sdkmanager --licenses
Warning: File /Users/user/.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

Then I had a list of 6 licenses to accept and its resolved after that.

Neel
  • 9,352
  • 23
  • 87
  • 128
4

It is because by default at the time of this writing , Ionic CLI tool is defaulted to

<preference name="android-targetSdkVersion" value="LATEST_SDK_VERSION"/> 

That is the reason why it complains that you did not accept license agreement , but in reality you did not install the SDK packages for that API Level yet alone accept the license.

So what you need to do is either

  1. Change Your target SDK version
  2. Install latest SDK API level from SDK Manager

Changing your SDK version

You can do it manually and even verify it by running

ionic cordova platform add android 

the file can be found at your-awesome-app/config.xml open it and add this line , since its hidden as stated above

<preference name="android-targetSdkVersion" value="24"/>

If you are not sure which API LEVEL Number you are targeting open SDK Manager and look at the API levels (Numbers) available on your machine

Installing Latest SDK Package

You can add the current SDK Packages which the CLI is showing , Which in your case it is 24

Run SDK MANAGER as Admin

Run SDK Manager as Admin

Install the SDK API Packages which you are targeting

Thats where the SDK API level are written

How did I know this? I did it this morning and that's how I solved it and now am playing Sticky Bubble on Android to relax a bit.

Happy Deploying!

Fahad
  • 1,943
  • 22
  • 27
4

In my case (Dockerfile script to build an Android CI container - https://github.com/menny/docker_android), I had to do these steps:

mkdir ~/.android && touch ~/.android/repositories.cfg
yes | sdkmanager --licenses
sdkmanager "build-tools;26.0.0"
sdkmanager "platform-tools" "tools"
sdkmanager "platforms;android-26" "platforms;android-25" "platforms;android-24"
.....
sdkmanager --update
yes | sdkmanager --licenses

Two notes:

  1. Had to create an empty repositories.cfg file or sdkmanager would die.
  2. Had to perform the fetching/installing of packages in different calls, since there is no progress indication.
Menny
  • 473
  • 6
  • 13
4

You can also follow the "official" way. Run "sdkmanager --licenses" within tools/bin folder of Android SDK installation and accept all licenses. Done!

c:\android-sdk\tools\bin>sdkmanager --licenses

For macOS or Linux it's the same command.

Georgy K
  • 255
  • 3
  • 10
3

It needs a latest stable sdk-platform installed. I installed SDK-Platform from API 25. It fixed my problem.See Screenshot below

Tushar Walzade
  • 3,737
  • 4
  • 33
  • 56
3

I had to update the android sdk

android update sdk --no-ui

at some point it will ask you for license agreement, press y. After that you need to remove the angular platform.

Tasnim Reza
  • 6,058
  • 3
  • 25
  • 30
3
  1. Go to Android SDK location

C:\Users\username\AppData\Local\Android\sdk\tools\bin

  1. Run command sdkmanager --licenses

  2. Accept the licence for SDK

Alexan
  • 8,165
  • 14
  • 74
  • 101
Inder malviya
  • 149
  • 1
  • 12
2

This issue is surfacing when already an old version of SDK Manager is in the machine from where the approach of Android build is Changed which requires "android studio". I faced this in Visual Studio that was repeatedly halted with Error Message, "You have not accepted the License for version 25". The solution for this is "Install the Android Studio" and then "go to Environment Variables" and set the ANDROID_HOME to "C:\Users\\AppData\Local\Android\Sdk" (This path can be picked from Android Studio, Menu >> Tools >> SDK Manager. Also use the same in "path" of Environment Variables. This way, the new SDK manager is mapped for pickup by Visual Studio Build for Cordova Application.

This just took my 2 days effort second time

Wish others don't waste their time in this mess.

1

Changing the target build might work as referenced here

If you want to specify the SDK version you can do so by adding the following line to your config.xml in the root of your ionic / cordova project

<preference name="android-targetSdkVersion" value="23"/>
Madhu Kumar
  • 395
  • 3
  • 11
1

you need to manually re-install sdk this help me: https://forum.ionicframework.com/t/you-have-not-accepted-the-license-agreements-of-the-following-sdk-component/69570/6

"android update sdk --no-ui --filter build-tools-24.0.0,android-24,extra-android-m2repository"

1

Hope this will work for someone out there
I was facing the same issue! I had 2 sdks, named as sdk and sdk1. It was default linked to sdk but the working one was sdk1. So I went to Environment Varaible and added ANDROID_HOME and path of the sdk1, i.e. in my case was C:\Users\tripa_000\AppData\Local\Android\sdk1 , and it solved my problem!

Tripathee Gaurav
  • 371
  • 3
  • 11
0

For me I was Building the Ionic using "ionic build android" command and I was getting the same problem! The solution was simply

  • To install the required sdk
  • Run the same command in CMD must be as administrater
Adel
  • 1,468
  • 15
  • 18
0

I just ran into this issue, and what solved it for me on windows, you are using command line, and you recently installed the android sdk, you must restart Command Prompt or Power Shell after you install the android sdk.

Norman Breau
  • 2,132
  • 16
  • 35
0

Mike's answer works.But need to put the generated license under C:\Users\user\AppData\Local\Android\sdk\licenses.

Thyagarajan C
  • 7,915
  • 1
  • 21
  • 25
0

its mean miss match Android SDK version of cordova with the version you installed. For an example cordova support Android SDK 24 but you don't have Android sdk 24. it may be reverse.

Yusuf
  • 703
  • 8
  • 13
0

This will update your android SDK and accept the license in the same time (ex for Android 25):

android update sdk --no-ui --filter build-tools-25.0.0,android-25,extra-android-m2repository

Yann Ulrich
  • 81
  • 1
  • 3
0

The problem for me was that my ANDROID_HOME variable was being set to another installation I forgot existed. If this is your problem, delete the old installation.

Cilan
  • 13,101
  • 3
  • 34
  • 51
0

install Android 7 - Platform 24 Full in android sdk manager

just it

Ali Gh
  • 680
  • 7
  • 9
0

If you want to avoid creating the licence folder manually, and in case your sdk is not in the "Users/User" you can go to android studio => Configure => SDK Manager and install any component, i installed the google usb driver from the sdk tools, it automatically generated the license in the correct location.

Mozart
  • 2,117
  • 2
  • 20
  • 38
0

For those who still have this issue, make sur the Android API of the target version is installed. Check it from the SDK Manager.

Then from the tools/bin folder, you can run sdkmanager --licenses

DeathCoder
  • 145
  • 1
  • 4
  • 19