简体   繁体   English

不能接受许可协议 Android SDK 平台24

[英]Can't accept license agreement Android SDK Platform 24

I'm getting the following error when trying to install an android platform on a Cordova project.尝试在 Cordova 项目上安装 android 平台时出现以下错误。 I've been following this guide: https://cordova.apache.org/docs/en/latest/guide/cli/我一直在关注本指南: https://cordova.apache.org/docs/en/latest/guide/cli/

Error occurs when executing the following: $ cordova platform add android --save执行以下命令时出错:$ cordova platform add android --save

A problem occurred configuring root project 'android'.配置根项目“android”时出现问题。 You have not accepted the license agreements of the following SDK components: [Android SDK Platform 24].您尚未接受以下 SDK 组件的许可协议:[Android SDK 平台 24]。

I've searched all over for ways to accept the license agreement of Android SDK Platform 24 , but no real luck.我已经到处寻找接受 Android SDK Platform 24 许可协议的方法,但没有真正的运气。

Thank you ahead of time.提前谢谢你。

You can also just execute你也可以只执行

$ANDROID_HOME/tools/bin/sdkmanager --licenses $ANDROID_HOME/tools/bin/sdkmanager --licenses

Or for Windows execute或者对于 Windows 执行

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

-- OR -- -- 或 --

C:\\Users{your-username}\\AppData\\Local\\Android\\sdk\\tools\\bin\\sdkmanager --licenses C:\\Users{您的用户名}\\AppData\\Local\\Android\\sdk\\tools\\bin\\sdkmanager --licenses

(credit for windows command to @puneet-kumar) (归功于@puneet-kumar 的 windows 命令)

I'm not exactly sure how cordova works, but once the licenses are accepted it creates a file.我不确定cordova 是如何工作的,但是一旦接受了许可,它就会创建一个文件。 You could create that file manually.您可以手动创建该文件。 It is described on this question , but here's the commands to create the required license file.这个问题中有描述,但这里是创建所需许可证文件的命令。

Linux: 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"

I had this problem on Mac OS X 10.12.1 with Cordova 6.4.0 and Android Studio 2.2.3.我在使用 Cordova 6.4.0 和 Android Studio 2.2.3 的 Mac OS X 10.12.1 上遇到了这个问题。

When I installed Android Studio it installed Platform 25, but not 24. To install 24:当我安装 Android Studio 时,它安装了 Platform 25,但没有安装 24。要安装 24:

  • Open Android Studio.打开安卓工作室。
  • Open Android Studio Menu > Preferences .打开Android Studio Menu > Preferences
  • Appearance & Behavior > System Settings > Android SDK
  • Tick the box for Android 7.0 (Nougat) | 24勾选适用于Android 7.0 (Nougat) | 24的复选框Android 7.0 (Nougat) | 24 Android 7.0 (Nougat) | 24
  • Click ok and follow the instructions.单击确定并按照说明进行操作。

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.为了继续您的开发工作,您需要对所有免责声明回答“y”。

I had exactly the same problem.我遇到了完全相同的问题。 Then i installed "Android 7.0 (API 24) > SDK Platform" and it worked.然后我安装了“Android 7.0 (API 24) > SDK Platform”并且它工作正常。

在此处输入图片说明

Go to Android\\sdk\\tools\\bin转到Android\\sdk\\tools\\bin

None of the above solutions worked for me and finally this single line accepted all android licences.上述解决方案都不适用于我,最后这一行接受了所有 android 许可证。

yes | sdkmanager --licenses && sdkmanager --update

In my case I don't use the Android studio (I am using eclipse).就我而言,我不使用 Android Studio(我使用的是 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.它创建了一个licenses目录,并在其中添加了一个名为android-sdk-license的文件。

Then you can run ( licenses option is not available unless you did the step above)然后您可以运行(除非您执行了上述步骤,否则licenses选项不可用)

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

and accept the license (however, in my case I didn't need to do that)并接受许可证(但是,就我而言,我不需要这样做)

I had the issue.我有这个问题。 You do not need to copy or to create any folder, just be careful of your SDK path.您无需复制或创建任何文件夹,只需注意您的 SDK 路径即可。 It must be the same of the environnement variable (ANDROID_HOME), which wasn't the same for me.它必须与环境变量 (ANDROID_HOME) 相同,这对我来说不一样。 I don't know why.我不知道为什么。

SDK位置

I installed android sdk build-tools 24(it's current version 24.0.3) through SDK manager.我通过 SDK 管理器安装了 android sdk build-tools 24(它是当前版本 24.0.3)。 Path to open SDK manager is shown in img file attached.打开 SDK 管理器的路径显示在附加的 img 文件中。 This solved my problem SDK Manager这解决了我的问题SDK Manager

I had the Android SDK by installing the Android Studio and got this error too.我通过安装 Android Studio 获得了 Android SDK,但也出现了此错误。 There's a simple solution from the user guide . 用户指南中有一个简单的解决方案。

  1. On a machine with Android Studio installed, click Tools > Android > SDK Manager .在安装了 Android Studio 的机器上,单击Tools > Android > SDK Manager At the top of the window, note the Android SDK Location .在窗口顶部,注意Android SDK Location

  2. Navigate to that directory and locate the licenses/ directory inside it.导航到该目录并找到其中的licenses/目录。

    (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.) (如果您没有看到licenses/目录,请返回 Android Studio 并更新您的 SDK 工具,确保接受许可协议。当您返回 Android SDK 主目录时,您现在应该会看到该目录。)

  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.复制整个licenses/目录并将其粘贴到您希望构建项目的机器上的Android SDK home directory

This error can come if the system is not picking up the ANDROID_HOME environmental variable from the proper path.如果系统没有从正确的路径中获取 ANDROID_HOME 环境变量,则可能会出现此错误。 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 SDK 并将 ANDROID_HOME 变量正确设置为适当的路径,如下图所示:

ANDROID_HOME_PATH 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).如果未定义 ANDROID_HOME 变量,系统会尝试从默认路径中选择路径(这可能不是定义 Android SDK 的路径,从而导致此问题)。

Prerequisites先决条件

Answer回答

  • Go to C:\\Users\\{user}\\AppData\\Local\\Android\\sdk\\tools\\bin (Your android SDK Tools folder)转到C:\\Users\\{user}\\AppData\\Local\\Android\\sdk\\tools\\bin (您的 android SDK 工具文件夹)

  • Run sdkmanager --licenses运行sdkmanager --licenses

  • It'll ask you to accept whatever the agreements remaining to be accepted.它会要求您接受尚待接受的任何协议。 you'll just have to type "y" and enter.你只需要输入“y”并输入。

  • Will solve the issue会解决问题

Install the following component:安装以下组件:

在此处输入图片说明

I am using Mac and I resolved it using this command:我正在使用 Mac,我使用以下命令解决了它:

$ 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.然后我列出了 6 个要接受的许可证,然后就解决了。

It is because by default at the time of this writing , Ionic CLI tool is defaulted to这是因为在撰写本文时,默认情况下, Ionic CLI工具默认为

<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.这就是为什么它抱怨您不接受许可协议,但实际上您没有安装该API级别的SDK 包而单独接受许可的原因。

So what you need to do is either所以你需要做的是

  1. Change Your target SDK version更改您的目标 SDK 版本
  2. Install latest SDK API level from SDK ManagerSDK Manager安装最新的 SDK API 级别

Changing your SDK version更改您的 SDK 版本

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该文件可以在your-awesome-app/config.xml打开它并添加这一行,因为它如上所述隐藏

<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如果您不确定您的目标是哪个API LEVEL 编号,请打开SDK Manager并查看您机器上可用的API 级别(编号)

Installing Latest SDK Package安装最新的 SDK 包

You can add the current SDK Packages which the CLI is showing , Which in your case it is 24您可以添加CLI显示的当前SDK 包,在您的情况下是24

Run SDK MANAGER as Admin管理员身份运行SDK MANAGER

以管理员身份运行 SDK Manager

Install the SDK API Packages which you are targeting安装您要定位的SDK API 包

这就是编写 SDK API 级别的地方

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.我今天早上做到了,这就是我解决它的方法,现在我正在Android上玩粘性泡泡来放松一下。

Happy Deploying!部署愉快!

In my case (Dockerfile script to build an Android CI container - https://github.com/menny/docker_android ), I had to do these steps:就我而言(构建 Android CI 容器的 Dockerfile 脚本 - https://github.com/menny/docker_android ),我必须执行以下步骤:

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.必须创建一个空的repositories.cfg文件,否则sdkmanager会死。
  2. Had to perform the fetching/installing of packages in different calls, since there is no progress indication.必须在不同的调用中执行包的获取/安装,因为没有进度指示。

You can also follow the "official" way.您也可以按照“官方”的方式进行。 Run " sdkmanager --licenses " within tools/bin folder of Android SDK installation and accept all licenses.在 Android SDK 安装的tools/bin文件夹中运行“ sdkmanager --licenses ”并接受所有许可。 Done!完成!

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

For macOS or Linux it's the same command.对于 macOS 或 Linux,这是相同的命令。

It needs a latest stable sdk-platform installed.它需要安装最新的稳定sdk 平台 I installed SDK-Platform from API 25. It fixed my problem.我从 API 25 安装了 SDK-Platform。它解决了我的问题。 请参阅下面的屏幕截图

I had to update the android sdk我不得不更新android sdk

android update sdk --no-ui

at some point it will ask you for license agreement, press y .在某些时候,它会要求您提供许可协议,请按y After that you need to remove the angular platform.之后,您需要移除角平台。

  1. Go to Android SDK location转到 Android SDK 位置

C:\\Users\\username\\AppData\\Local\\Android\\sdk\\tools\\bin C:\\Users\\用户名\\AppData\\Local\\Android\\sdk\\tools\\bin

  1. Run command sdkmanager --licenses运行命令sdkmanager --licenses

  2. Accept the licence for SDK接受 SDK 许可

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".当旧版本的 SDK Manager 已在更改 Android 构建方法的机器中时,此问题就会出现,这需要“android studio”。 I faced this in Visual Studio that was repeatedly halted with Error Message, "You have not accepted the License for version 25".我在 Visual Studio 中遇到过这个问题,该问题因错误消息“您尚未接受版本 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.对此的解决方案是“安装 Android Studio”,然后“转到环境变量”并将 ANDROID_HOME 设置为“C:\\Users\\\\AppData\\Local\\Android\\Sdk”(此路径可以从 Android Studio、Menu >> 工具 >> SDK 管理器。在环境变量的“路径”中也使用相同的。这样,新的 SDK 管理器被映射以供 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.希望其他人不要在这个烂摊子上浪费时间。

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如果要指定 SDK 版本,可以通过将以下行添加到 ionic/cordova 项目根目录中的 config.xml 来实现

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

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您需要手动重新安装 sdk 这对我有帮助: 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" “android 更新 sdk --no-ui --filter build-tools-24.0.0,android-24,extra-android-m2repository”

Hope this will work for someone out there希望这对外面的人有用
I was facing the same issue!我面临同样的问题! I had 2 sdks, named as sdk and sdk1.我有 2 个 sdk,分别命名为 sdk 和 sdk1。 It was default linked to sdk but the working one was sdk1.它默认链接到 sdk,但工作的是 sdk1。 So I went to Environment Varaible and added ANDROID_HOME and path of the sdk1, ie in my case was C:\\Users\\tripa_000\\AppData\\Local\\Android\\sdk1 , and it solved my problem!所以我去了环境变量并添加了ANDROID_HOME和 sdk1 的路径,即在我的情况下是C:\\Users\\tripa_000\\AppData\\Local\\Android\\sdk1 ,它解决了我的问题!

For me I was Building the Ionic using "ionic build android" command and I was getting the same problem!对我来说,我正在使用“ionic build android”命令构建 Ionic,但我遇到了同样的问题! The solution was simply解决方法很简单

  • To install the required sdk安装所需的sdk
  • Run the same command in CMD must be as administrater在 CMD 中运行相同的命令必须以管理员身份运行

我刚遇到这个问题,在 Windows 上为我解决了什么问题,您使用的是命令行,并且您最近安装了 android sdk,安装 android sdk 后必须重新启动命令提示符或 Power Shell。

Mike 的回答有效。但需要将生成的许可证放在 C:\\Users\\user\\AppData\\Local\\Android\\sdk\\licenses 下。

its mean miss match Android SDK version of cordova with the version you installed.它的平均未匹配 Android SDK 版本的cordova 与您安装的版本。 For an example cordova support Android SDK 24 but you don't have Android sdk 24. it may be reverse.例如,cordova 支持 Android SDK 24,但您没有 Android sdk 24。它可能相反。

This will update your android SDK and accept the license in the same time (ex for Android 25):这将更新您的 android SDK 并同时接受许可证(例如 Android 25):

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

The problem for me was that my ANDROID_HOME variable was being set to another installation I forgot existed.我的问题是我的 ANDROID_HOME 变量被设置为我忘记存在的另一个安装。 If this is your problem, delete the old installation.如果这是您的问题,请删除旧安装。

install Android 7 - Platform 24 Full in android sdk manager在 android sdk 管理器中安装 Android 7 - 平台 24

just it只是它

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. 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 sdk 工具,它会自动在正确的位置生成许可证。

For those who still have this issue, make sur the Android API of the target version is installed.对于仍有此问题的用户,请安装目标版本的 Android API。 Check it from the SDK Manager.从 SDK 管理器检查它。

Then from the tools/bin folder, you can run sdkmanager --licenses然后从 tools/bin 文件夹中,您可以运行sdkmanager --licenses

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM