ionic cordova build 错误:无法安装 android sdk 包

Posted

技术标签:

【中文标题】ionic cordova build 错误:无法安装 android sdk 包【英文标题】:ionic cordova build error: Failed to install android sdk packages 【发布时间】:2021-07-13 21:13:19 【问题描述】:

我试图从 ionic cordova 项目生成 apk 文件,在我的 ubuntu 机器上安装 jdk 和 android-sdk 后,设置路径变量并执行“ionic cordova platform add android”我执行了命令“ionic cordova build android",运行一段时间后产生以下错误。

请告诉我我需要做什么,我整天都在做这个。

Starting a Gradle Daemon (subsequent builds will be faster)
WARNING: The specified Android SDK Build Tools version (27.0.1) is ignored, as it is below the minimum supported version (29.0.2) for Android Gradle Plugin 4.0.0.
Android SDK Build Tools 29.0.2 will be used.
To suppress this warning, remove "buildToolsVersion '27.0.1'" from your build.gradle file, as each version of the Android Gradle Plugin now has a default version of the build tools.
WARNING: The specified Android SDK Build Tools version (27.0.1) is ignored, as it is below the minimum supported version (29.0.2) for Android Gradle Plugin 4.0.0.
Android SDK Build Tools 29.0.2 will be used.
To suppress this warning, remove "buildToolsVersion '27.0.1'" from your build.gradle file, as each version of the Android Gradle Plugin now has a default version of the build tools.
Observed package id 'build-tools;debian' in inconsistent location '/usr/lib/android-sdk/build-tools/27.0.1' (Expected '/usr/lib/android-sdk/build-tools/debian')
Observed package id 'build-tools;debian' in inconsistent location '/usr/lib/android-sdk/build-tools/27.0.1' (Expected '/usr/lib/android-sdk/build-tools/debian')
File /root/.android/repositories.cfg could not be loaded.
Checking the license for package Android SDK Build-Tools 29.0.2 in /usr/lib/android-sdk/licenses
Warning: License for package Android SDK Build-Tools 29.0.2 not accepted.
Checking the license for package Android SDK Platform 29 in /usr/lib/android-sdk/licenses
Warning: License for package Android SDK Platform 29 not accepted.

FAILURE: Build failed with an exception.

* What went wrong:
Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'.
> Failed to install the following Android SDK packages as some licences have not been accepted.
     build-tools;29.0.2 Android SDK Build-Tools 29.0.2
     platforms;android-29 Android SDK Platform 29
  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

  Using Android SDK: /usr/lib/android-sdk

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 28m 36s

【问题讨论】:

【参考方案1】:

你需要接受许可,打开android studio,你会找到configure按钮,点击那里进入manage sdk。 更简单的方法是在 android studio 中创建一个空白项目并构建它也将接受条款。

here is where you will find it

【讨论】:

我可以在 ubuntu 终端不使用 android studio 的情况下做到这一点吗?我的机器不够强大,无法运行 android studio。请告诉我如何从我安装了 android sdk 的终端接受许可证 hm 我从来没有在没有 android studio 的情况下做过,但这个答案显示了如何使用终端接受许可证:***.com/questions/39760172/…

以上是关于ionic cordova build 错误:无法安装 android sdk 包的主要内容,如果未能解决你的问题,请参考以下文章

ionic cordova build --prod --release 失败并产生错误

Cordova / Ionic build android Gradle 错误:支持的最低 Gradle 版本为 2.14.1。当前版本是 2.13

Ionic 2: - prod文件未编译错误:build prod failed:无法确定类HomePage的模块

ionic cordova build 显示 lint 警告

ionic cordova build android 报错 解决

ionic cordova build android - 失败