“./gradlew assembleRelease”错误:由于未接受许可证而无法安装 Android SDK 包

问题描述 投票:0回答:1

背景:

我在尝试使用“./gradlew assembleRelease”构建 Android 应用程序的发布版本时遇到问题。我已经使用命令

sdkmanager --licenses
接受了所有 Android SDK 许可证,并且它确认所有许可证均已接受。

问题:

但是,我继续收到以下错误:

尽管多次重新接受许可证,错误仍然存在。

错误信息:

PS D:\documents\vscode\nodejs\start-sphere\android> ./gradlew assembleRelease
...

> Configure project :expo

Using expo modules
  - expo-asset (10.0.10)
  - expo-constants (16.0.2)
  - expo-file-system (17.0.1)
  - expo-font (12.0.8)
  - expo-keep-awake (13.0.2)
  - expo-modules-core (1.12.19)
  - expo-speech (12.0.2)

Checking the license for package Android SDK Build-Tools 34 in C:\Program Files\Android\SDK\cmdline-tools\tools\bin\licenses
Warning: License for package Android SDK Build-Tools 34 not accepted.
Checking the license for package Android SDK Platform 34 in C:\Program Files\Android\SDK\cmdline-tools\tools\bin\licenses
Warning: License for package Android SDK Platform 34 not accepted.

FAILURE: Build failed with an exception.

* What went wrong:
Could not determine the dependencies of task ':app:lintVitalReportRelease'.
> Failed to install the following Android SDK packages as some licences have not been accepted.
     platforms;android-34 Android SDK Platform 34
     build-tools;34.0.0 Android SDK Build-Tools 34
  To build this project, accept the SDK license agreements and install the missing components using the Android Studio SDK Manager.
  All licenses can be accepted using the sdkmanager command line tool:
  sdkmanager --licenses
  Or, to transfer the license agreements from one workstation to another, see https://developer.android.com/studio/intro/update.html#download-with-gradle

  Using Android SDK: C:\Program Files\Android\SDK\cmdline-tools\tools\bin

* 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 11s
5 actionable tasks: 1 executed, 4 up-to-date

任何有关如何解决此问题的见解或建议将不胜感激。谢谢!

尝试:

我已尝试以下故障排除步骤:

  • 重新运行
    sdkmanager --licenses
  • 确保 SDK 路径在我的环境中正确配置。
  • 清理并重建项目。
android react-native gradle expo gradlew
1个回答
0
投票

您可以在该命令前面使用

yes |
自动接受许可证。如果您在 CLI 上运行。

接受许可证的正确命令是这样的:

yes | sdkmanager --licenses

对于特定的构建工具,它将是:

echo yes | $ANDROID_HOME/tools/bin/sdkmanager "build-tools;34.0.0"

您还可以分享一下从 android studio 接受许可证的步骤吗?

阅读这篇文章了解更多信息:

© www.soinside.com 2019 - 2024. All rights reserved.