SDK 管理器一些许可证尚未被接受

SDK Manager some Licenses Have not been Accepted

我在尝试 运行 ./gradlew build

时遇到以下错误
Could not determine the dependencies of task ':app:compileReleaseJavaWithJavac'.
> 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

但是当我 运行 ./sdkmanager --licenses 我得到:

Warning: File /var/jenkins_home/.android/repositories.cfg could not be loaded.
All SDK package licenses accepted.======] 100% Computing updates...

我犯了一个愚蠢的错误,我使用的 xmartlabs/jenkins-android 图像根据其 DockerfileANDROID_HOME 设置为 /opt/android-sdk-linux。错误中也提到了,我没有注意到。无论如何,我最终在一个单独的目录中创建了一个 android sdk,在该目录中接受了许可,因此不断出现未接受的许可协议错误。