未接受包 Android SDK 平台 29 的许可证

License for package Android SDK Platform 29 not accepted

我在 Ubuntu 20.04 中安装了 cordova,当我尝试构建时,我看到消息 License for package Android SDK Platform 29 not accepted

我已经 sdkmanager --license 并接受所有许可,但它仍在发生。怎么了?

我的环境设置在.bashrc

export ANDROID_SDK_ROOT=/usr/lib/android-sdk
export ANDROID_HOME=/usr/lib/android-sdk
export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
export PATH=${PATH}:/usr/lib/android-sdk/platform-tools:/usr/lib/android-sdk/tools
export PATH=$ANDROID_HOME/cmdline-tools/tools/bin:$PATH

完整的错误信息:

Checking Java JDK and Android SDK versions
ANDROID_SDK_ROOT=undefined (recommended setting)
ANDROID_HOME=undefined (DEPRECATED)
Using Android SDK: /usr/lib/android-sdk
Subproject Path: CordovaLib
Subproject Path: app
Starting a Gradle Daemon, 1 incompatible and 1 stopped Daemons could not be reused, use --status for details

> Configure project :CordovaLib
[Cordova] cdvMinSdkVersion is overridden, try it at your own risk.
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 SDK Patch Applier v4 in /usr/lib/android-sdk/licenses
Warning: License for package SDK Patch Applier v4 not accepted.
Checking the license for package Android Emulator in /usr/lib/android-sdk/licenses
Warning: License for package Android Emulator not accepted.
Checking the license for package Android SDK Tools in /usr/lib/android-sdk/licenses
Warning: License for package Android SDK Tools not accepted.
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.
     patcher;v4 SDK Patch Applier v4
     platforms;android-29 Android SDK Platform 29
     emulator Android Emulator
     tools Android SDK Tools
     build-tools;29.0.2 Android SDK Build-Tools 29.0.2
  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 29s
Command failed with exit code 1: /home/pedro/Developer/Apps/MyApp/cordova/platforms/android/gradlew cdvBuildDebug -b /home/pedro/Developer/Apps/MyApp/cordova/platforms/android/build.gradle
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! my-app@1.0.0 build-cordova-android: `node ./build/build.js && cd cordova && cordova build android`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the my-app@1.0.0 build-cordova-android script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2021-06-05T11_01_39_133Z-debug.log

AndroidSDK 终于可以接受许可了。

yes | sdkmanager --licenses

从命令行接受许可协议的方式已经改变。您可以使用位于以下位置的 SDK 管理器:$ANDROID_SDK_ROOT/tools/bin

例如 linux:

cd ~/Library/Android/sdk/tools/bin/

为了解决这个问题,我不得不安装 Android Studio。出现同样的错误,但单击一下我就被重定向到一个 GUI,其中有一个屏幕可以接受和下载 SDK Platform 29