报错: Failed to install the following Android SDK packages as some licences have not been accepted.

导入已有的工程,在 build 时出现了 Failed to install the following Android SDK packages as some licences have not been accepted. 从此开启有点漫长的脱坑之路。

出现这个为在解决后发现主要是两个问题:

        一个是 sdkmanager 没有更新;

        另一个原因是项目配置的 build-tools  platforms platform-tools 和本地下载的版本存在不一致的情况。

Failed to install the following Android SDK packages as some licences have not been accepted.
   platforms;android-28 Android SDK Platform 28
   build-tools;27.0.3 Android SDK Build-Tools 27.0.3
To build this project, accept the SDK license agreements and install the missing components using the Android Studio SDK Manager.
Alternatively, to transfer the license agreements from one workstation to another, see http://d.android.com/r/studio-ui/export-licenses.html

上面报错的同事 java 编译器还提示:

        Warning: License for package Android SDK Build-Tools 27.0.3 not accepted.
        Warning: License for package Android SDK Platform 28 not accepted.

解决:

1、先 cd 到 安装sdk 的 tools/bin 目录下:如 cd /home/xxxxx/xxx/00_soft/sdk/android-sdk-linux/tools/bin

      在没有更新 sdkmanager 之前,该文件夹下只有一个 sdkmanager 可执行文件

2、执行命令  ./sdkmanager --update (执行过程有点慢,不知道是不是网速问题)

       执行结束后 bin 文件夹下的内容如下:

drwxr-xr-x 2 a5673 a5673 4096 7月  16 10:49 .
drwxr-xr-x 6 a5673 a5673 4096 7月  16 10:49 ..
-rwxr-xr-x 1 a5673 a5673 6742 7月  16 10:49 apkanalyzer
-rwxr-xr-x 1 a5673 a5673 5253 7月  16 10:49 archquery
-rwxr-xr-x 1 a5673 a5673 6040 7月  16 10:49 avdmanager
-rwxr-xr-x 1 a5673 a5673 5250 7月  16 10:49 jobb
-rwxr-xr-x 1 a5673 a5673 6834 7月  16 10:49 lint
-rwxr-xr-x 1 a5673 a5673 3323 7月  16 10:49 monkeyrunner
-rwxr-xr-x 1 a5673 a5673 5613 7月  16 10:49 screenshot2
-rwxr-xr-x 1 a5673 a5673 6047 7月  16 10:49 sdkmanager
-rwxr-xr-x 1 a5673 a5673 3076 7月  16 10:49 uiautomatorviewer

3、再次执行命令 : ./sdkmanager --license 更新 license 文件,执行过程需要多次确认

:~/xxx/00_soft/sdk/android-sdk-linux/tools/bin$ ./sdkmanager --licenses
4 of 5 SDK package licenses not accepted. 100% Computing updates...             
Review licenses that have not been accepted (y/N)? y

4、这时可以尝试是否能够正常构建项目,有可能遇到下面提示的问题(或是其中的一个提示)

        Warning: License for package Android SDK Build-Tools 27.0.3 not accepted.
        Warning: License for package Android SDK Platform 28 not accepted.

      应该是本地下载的版本和配置的没有对应上,只需要通过 sdkmanager 下载项目配置的版本即可。

      例如(具体请了解 sdkmanager 命令的使用):

// 同时安装多个包
sdkmanager "platform-tools" "build-tools;28.0.3" "platforms;android-28"

 

你可能感兴趣的:(报错: Failed to install the following Android SDK packages as some licences have not been accepted.)