How to accept Android license agreements in Visual Studio

Viewed 2051

I am using Visual Studio Tools for Apache Cordova, and I recently changed the Cordova CLI version (to 6.5.0)

Now when I attempt to build my solution I get an error:

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

Is there a way to accept the license agreements without having to download and install the Android Studio SDK Manager too?

2 Answers

I was able to solve this in Visual Studio 2017 after noticing in the output that it had the following a few lines up before the error:

ANDROID_HOME=C:\ProgramData\Microsoft\AndroidSDK\25

I then went and copied this folder and it's contents:

C:\Program Files (x86)\Android\android-sdk\licenses

over to the one Visual Studio was using here:

C:\ProgramData\Microsoft\AndroidSDK\25\licenses

After that the following build complained

The SDK directory (C:\ProgramData\Microsoft\AndroidSDK\25) is not writeable

Which is simply solved by making it not read-only in Explorer and tweaking the security and then it built.

Also looks like you can change the URL of ANDROID_HOME under the Options menu

The easiest way to fix this is to locate the files on disk, eg: "C:\Program Files (x86)\Android\android-sdk" (you can see where Visual Studio gets them from in "Tools" > "Options" > "Tools For Apache Cordova" > "Environment Variable Overrides", then see what you have in ADT_HOME).

Run "SDK Manager.exe" from there, and manually install the API level 25.

Note that if this doesn't work or your SDK is too old. You might need to uninstall the Android SDK, and reinstall it (see http://taco.visualstudio.com/en-us/docs/configure-vs-tools-apache-cordova/#ThirdParty)

Related