Ionic build error : You have not accepted the lice

2019-02-03 23:26发布

问题:

I'm trying to run the command ionic build android --release to build the apk but i am getting this error

Total time: 1.767 secs Error: cmd: Command failed with exit code 1 Error output: 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 24]. 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

  • Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Picked up _JAVA_OPTIONS: -Xmx512M

回答1:

Install the license:

mkdir "%ANDROID_HOME%\licenses"

echo |set /p="8933bad161af4178b1185d1a37fbf41ea5269c55" > "%ANDROID_HOME%\licenses\android-sdk-license"



回答2:

Install Platform 24 (Android 7) solved this problem



回答3:

I solved it by installing the Android SDK Platform 24 without the Android SDK manager.

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

*Cordova CLI 6.4.0 / Windows 10



回答4:

In Command Prompt, go to ANDROID_HOME\tools\bin

Then run the command, sdkmanager --licenses

Accept the licenses you want when it is prompted.



回答5:

Above peter wang's answer worked for me after setting the ANDROID_HOME environment variable. in my case ANDROID_HOME was C:\Users\YourUserName\AppData\Local\Android\android-sdk

After that below commands resulted in a successful build.

mkdir "%ANDROID_HOME%\licenses"
echo |set /p="8933bad161af4178b1185d1a37fbf41ea5269c55" > "%ANDROID_HOME%\licenses\android-sdk-license"


回答6:

My software:

Ubuntu 16.04.2 LTS
Gradle 3.5
java version "1.8.0_131"
$ANDROID_HOME = ~/AndroidSDK

Working solution:

yes | $ANDROID_HOME/tools/bin/sdkmanager "build-tools;25.0.2

of course you should use your version of build-tools.

Source:

Automatically accept all SDK licences



回答7:

This worked for me under ubuntu :

mkdir "$ANDROID_SDK/licenses" || true
echo -e "\n8933bad161af4178b1185d1a37fbf41ea5269c55" > "$ANDROID_SDK/licenses/android-sdk-license"
echo -e "\n84831b9409646a918e30573bab4c9c91346d8abd" > "$ANDROID_SDK/licenses/android-sdk-preview-license"

source: Dori's answer to automatically-accept-all-sdk-licences



回答8:

I had the same issue and I used @peters.Wang answer to generate license and placed license folder inside sdk folder.

Thanks to @peters.Wang



回答9:

Install sdk 25 and accept the license from android studio. That solved my issues.



回答10:

I've solved my problem with this.

mkdir "%ANDROID_HOME%\licenses"

echo |set /p="8933bad161af4178b1185d1a37fbf41ea5269c55" > "%ANDROID_HOME%\licenses\android-sdk-license"


回答11:

You have to follow the helper text after

You have not accepted the license agreements of the following SDK components: in this situation you have to install [Android SDK Platform 24]. in fact the helper text in bracket [] drives you to the right way.



回答12:

I solved the problem by checking file android-sdk-licenses in Installed ANdroid path for ex my path G:\Android\sdk\licenses with the same file present in this directory C:\Users\Ashutosh\AppData\Local\Android\Sdk\licenses copy all the licenses if more than one :)



回答13:

I had same situation and all of the above suggestion did not work because either my installation and component folder names are different or the files are in different places.

I had old installation of Android Studio in C and new in E. I had uninstalled the old version but Android studio did not clear all files and reset my Env. Variable. So I simply did following

1) Searched for this file: android-sdk-license

2) See if above file is in folder Licenses surrounded by other folders like add-ons, build-tools, emulator etc.

3) Then make sure ANDROID_HOME is pointing to this parent folder of Licenses.



回答14:

You will run into an issue like this whenever your Android Studio's packages are outdated, as building will occur in the latest stable releases. To fix, do the following:

Android Studio > Preferences > Appearance & Behavior > System Settings > Android SDK Tick the latest Android versions (or what you need), click Apply. It's at this point where Android will ask you to agree to its license(s) and the updated version(s) will be installed.

Now you can Ionic / Cordova / PhoneGap build / run.



回答15:

  1. Go to C:\Users\<UserName>\AppData\Local\Android\Sdk\tools\bin
  2. Run command ./sdkmanager.bat --licenses
  3. accept license

Worked for me



回答16:

If you are having issues coming from a newer version of Android SDK then change your target version in your config.xml.

Next, open Android Studio>Configure>SDK Manager

Check the version you need for 24 use 7.0 and check it. Then install it and try to build again.



回答17:

Install the latest Android Studio and accept the license agreement.

https://developer.android.com/studio/index.html