Azure Devops 构建 - 警告:不接受包 Android SDK 构建工具 28.0.3 的许可证

Azure Devops Build - Warning: License for package Android SDK Build-Tools 28.0.3 not accepted

我的 Android ReactNative 项目正在使用 Azure Build Pipeline 进行集成和打包。几个月来它运行良好,但几天前我开始收到此错误:

Warning: License for package Android SDK Build-Tools 28.0.3 not accepted

我尝试了不同的代理,但没有成功。

常见的解决方案建议签入许可证文件,但有更好的解决方法吗?找不到很多其他人谈论这个,因此我认为这不是 Azure Build Pipleline 的问题。

[command]C:\Program Files\Git\bin\bash.exe D:\a\s\android\gradlew assembleRelease
Downloading https://services.gradle.org/distributions/gradle-4.6-all.zip

... 

Checking the license for package Android SDK Build-Tools 28.0.3 in C:\Program Files (x86)\Android\android-sdk\licenses
Warning: License for package Android SDK Build-Tools 28.0.3 not accepted.
FAILURE: Build failed with an exception.

我找到了 temp workaround here。基本上在构建开始时添加一个 PowerShell 步骤并设置许可证。似乎是所有 Android 相关构建的问题。

转到 Android SDK 根文件夹(其中包含 tools 文件夹)

如果许可文件夹不存在则创建许可文件夹

如果 licenses 文件夹不存在,则创建 android-sdk-license 文件

打开 android-sdk-license 文件作为文本文件(使用记事本)

将以下内容粘贴到文件中并保存

8933bad161af4178b1185d1a37fbf41ea5269c55
d56f5187479451eabf01fb78af6dfcb131a6481e
24333f8a63b6825ea9c5514f83c2829b004d1fee

许可证位置:sdkpath\licenses\android-sdk-license