3

I'm trying to run my Ionic 3 project on my Android device with ionic cordova run android --device --stacktrace, but, I've the following output:

...

Checking the license for package Android SDK Platform 26 in C:\Android\android-sdk\licenses Warning: License for package Android SDK Platform 26 not accepted.

FAILURE: Build failed with an exception.

  • What went wrong: A problem occurred configuring root project 'android'.

You have not accepted the license agreements of the following SDK components: [Android SDK Platform 26]. 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

Reading other questions, people suggested using the Android Studio SDK manager and installing the latest versions, because then I would be asked about the licenses and would have to accept them, so I installed Android 8.0 (Oreo) and Android API 27 which are the last available updates, however, at no time was I asked about any license and the error persisted. My device is connected to the PC (Windows 10) via the USB cable and the programmer mode is enabled along with USB debugging. What can I do to resolve this?

My SDK manager:

My SDK manager

Update:

I already ran the command sdkmanager --licenses in the C:\Android\sdk\tools\bin and C:\Users\User\AppData\Local\Android\sdk\tools\bin folders and all the missing licenses were accepted, but the error continues.

My cordova-android version in package.json: "cordova-android": "~6.3.0" and in config.xml: <engine name="android" spec="~6.3.0" /> (already tried with 6.3.0 and 6.2.0 without success)

Following the error:

Checking the license for package Android SDK Platform 26 in C:\Android\android-sdk\licenses Warning: License for package Android SDK Platform 26 not accepted.

But I don't have the licenses folder in C:\Android\android-sdk, just in C:\Android\sdk. How I do for Ionic check for the folder where the licenses really are?

ionic info:

cli packages: (C:\Users\User\AppData\Roaming\npm\node_modules)

    @ionic/cli-utils  : 1.19.0
    ionic (Ionic CLI) : 3.19.0

global packages:

    cordova (Cordova CLI) : 7.1.0

local packages:

    @ionic/app-scripts : 3.1.0
    Cordova Platforms  : none
    Ionic Framework    : ionic-angular 3.9.2

System:

    Node : v6.11.2
    npm  : 3.10.10
    OS   : Windows 10

Environment Variables:

    ANDROID_HOME : C:\Android\android-sdk

Misc:

    backend : pro
Igor
  • 645
  • 4
  • 16
  • 37
  • Update your node js, ionic,npm,android/ios version.. – Madpop Dec 30 '17 at 07:13
  • @igor what is the version of the `cordova-android` – Krsna Kishore Jan 02 '18 at 10:29
  • Following the instructions [in this question](https://stackoverflow.com/questions/39760172/you-have-not-accepted-the-license-agreements-of-the-following-sdk-components) solved the problem for me. – Phonolog Jan 02 '18 at 16:08
  • @Igor Go to your $ANDROID_HOME/tools/bin in command prompt and try executing the command - "./sdkmanager --licenses". Then accept All licenses listed there. – Gandhi Jan 03 '18 at 13:36
  • @Webruster `"cordova-android": "~6.3.0"` – Igor Jan 04 '18 at 16:09
  • @Phonolog but not for me :/ – Igor Jan 04 '18 at 16:12
  • @Gandhi I accepted all the licenses that were missing, but the error continues. – Igor Jan 04 '18 at 16:15
  • @Igor did you had a look at the suggestions in this link - https://stackoverflow.com/questions/39760172/you-have-not-accepted-the-license-agreements-of-the-following-sdk-components – Gandhi Jan 04 '18 at 18:56
  • @Gandhi yes, I've tried all the suggestions and the error continues. I edited my question with some updates. – Igor Jan 05 '18 at 00:36
  • Your cordova-android version is 6.3.0 but you don't have android 23 sdk build tools installed. In your sdk manager, select android 6.0 and make sure the build tools is also selected, then accept the license and install. Should resolve the issue. – Ikenna Anthony Okafor Jan 05 '18 at 07:41
  • @IkennaAnthonyOkafor As per the OP's screenshot, android 26 sdk is installed which is compatible for cordova android version 6.3.0 – Gandhi Jan 05 '18 at 08:01

10 Answers10

22

In SDK folder you have to run under command prompt.

...\sdk\tools\bin

Enter this command

sdkmanager "platforms;android-26"
Paresh Gami
  • 4,777
  • 5
  • 23
  • 41
  • 1
    Also solves same problem for me with `react-native run android`. Need to supply the platform number and name that the process is complaining about, in my case `"platforms;android-28"`. – Hugh Barnard Apr 08 '19 at 07:37
  • @HughBarnard Thanks for sharing information. #KeepSharing – Paresh Gami Apr 08 '19 at 08:05
5

Solved! Reading the information on the page http://tools.android.com/tech-docs/new-build-system/license:

...

If you have accepted the license agreements on one workstation, but wish to build your projects on a different one, you can export your licenses by copying the accepted licenses folder from the Android Sdk Home folder

...

So I just went to C:\Android\sdk and copied the licenses folder to the C:\Android\android-sdk folder which was where Ionic was searching for the licenses.

Thanks to all who have somehow tried to help.

Igor
  • 645
  • 4
  • 16
  • 37
  • 1
    But i guess you dint mentioned about accepting license in one workstation and building at a different one in question. – Gandhi Jan 07 '18 at 18:37
  • But I built all at the same workstation, however, the error occurred anyway – Igor Jan 07 '18 at 18:47
  • But its strange that how the licenses folder got created outside android home folder – Gandhi Jan 08 '18 at 12:49
1

Check your cordova-android version . Try to run with the cordova-android version 6.2.3 .

if the above solution doesn't work follow this process.

  1. Download android studio SDK Manager

  2. Download the SDK for version 26.

    https://developer.android.com/studio/intro/update.html

Update

based on your Update you are adding the version in your package.json as follows

"cordova-android": "~6.3.0" so change this to following format as follows "cordova-android": "6.3.0" Reference to the Issue

Note if the above format doesn't work for the 6.3.0 , try the same with the 6.2.0 as follows "cordova-android": "6.2.0"

Community
  • 1
  • 1
Krsna Kishore
  • 8,233
  • 4
  • 32
  • 48
  • Run with version `6.2.3` didn't work for me (the error continues). But I already have the SDK for version 26 (print screen in the question) – Igor Jan 05 '18 at 00:51
  • Tried with `6.3.0` and `6.2.0` but without success again, insisting that I didn't accept the Android SDK Platform 26 license. Added more info in question update. – Igor Jan 05 '18 at 14:22
0

In my case, using Visual Studio + Cordova, this case was solved by copying "licenses" folder from your %ANDROID_HOME% folder to "C:\ProgramData\Microsoft\AndroidSDK\25", VS took licenses from there.

Serg Tomcat
  • 812
  • 10
  • 21
0

Go to the android sdk folder, copy the licenses folder from there, and paste the folder to the path below:

C:\Users\intel\AppData\Local\Android\Sdk
sɐunıɔןɐqɐp
  • 3,332
  • 15
  • 36
  • 40
0

After I installed version which was asked for licenses - it started to work! You can do this in Android Studio > SDK Manager

Gediminas Šukys
  • 7,101
  • 7
  • 46
  • 59
0

@Paresh Gami's answer helped resolve mine. Just a side note for Mac OSX user..

the full path is /Users/useraccount/Library/Android/sdk/tools/bin/

where useraccount is your current system user.

0

os : windows 7 (64 bit)

you can accept SDK lic agreement using blow command :

goto the "C:\Users{user_name}\AppData\Local\Android\sdk\tools\bin"

Execute command : sdkmanager "platforms;android-xx"

node : xx is the version

praveen kedar
  • 188
  • 2
  • 5
0

I did tried above mention tricks, what works for me on Mac OS is below

$ANDROID_HOME/tools/bin/sdkmanager "build-tools;26.0.1" "platforms;android-26"
Anjum....
  • 4,086
  • 1
  • 35
  • 45
0

In latest SDK you can find sdkmanager file under this location

/Users/pareshgami/Library/Android/sdk/cmdline-tools/latest/bin/

after that we need to run same command

sdkmanager "platforms;android-26"
Paresh Gami
  • 4,777
  • 5
  • 23
  • 41