Android SDK许可问题阻止了在IntelliJ中构建LibGDX项目。

huangapple go评论81阅读模式
英文:

Android SDK license issue prevents build of LibGDX project in IntelliJ

问题

重新安装了Windows 10之后,我拼命地尝试在IntelliJ中再次运行我的LibGDX项目。由于Android SDK许可问题,它无法构建。

我重新安装了Android Studio和之前在项目中使用的Android SDK 27,但是我收到了以下错误消息:

> 配置项目':android'时出现问题。
> 由于某些许可证尚未被接受,无法安装以下Android SDK包。
> platform-tools Android SDK平台工具
patcher;v4 SDK修补程序应用程序v4
platforms;android-27 Android SDK平台27
build-tools;27.0.3 Android SDK构建工具27.0.3
emulator Android模拟器
tools Android SDK工具


我找到了以下有许多建议修复方法的线程:

https://stackoverflow.com/q/54273412

所以我了解到我必须运行

%ANDROID_HOME%/tools/bin/sdkmanager --licenses

起初它没有起作用,因为文件/users/MYUSERNAME/.android/repositories.cfg不存在。我在那个路径下创建了一个空文件,再次运行了sdkmanager,并接受了所有许可证。然而,当我在IntelliJ中构建我的LibGDX项目时,仍然收到相同的错误。


以下是我尝试解决这个问题的方法:

  • 以管理员权限运行sdkmanager --licenses
  • 运行sdkmanager --update而不是--licenses
  • 安装了Android命令行工具,并使用了那个sdkmanager批处理文件
  • 确保%ANDROID_HOME%\licenses文件夹存在并包含许可证文件
  • 确保我的机器上没有安装另一个我不知道的Android SDK - ANDROID_HOMEANDROID_SDK_ROOT(我读到前者已过时)环境变量都指向相同的文件夹,该文件夹在Android Studio SDK管理器中也配置为Android SDK位置,在我的IntelliJ项目设置中也配置为Android SDK主目录
  • 选择了随Android Studio一起提供的JRE作为我的机器上的标准Java运行时环境(通过将JAVA_HOME设置为C:\Program Files\Android\Android Studio\jre
  • 卸载了随Android Studio自动安装的API 30 SDK,这样我只剩下API 27
  • 尝试在我的LibGDX项目的android\build.gradle文件中配置,使用API 30 SDK代替API 27
  • 卸载了Android Studio,删除了SDK文件夹,并重新安装了一切
  • 在我的gradlew.bat中添加了yes | sdkmanager --licenses

这些方法似乎都没有帮助。当我再次运行sdkmanager --licenses时,回复是

> 所有SDK包许可证已被接受。

但IntelliJ仍然显示相反的结果。

我已经没有解决办法了。非常感谢任何帮助。

英文:

After reinstalling Windows 10, I am desperately trying to get my LibGDX project to run in IntelliJ again. It will not build because of an Android SDK license issue.

I reinstalled Android Studio and the Android SDK 27, which I had been using in my project before, but I got the following error message:

> A problem occurred configuring project ':android'.
> Failed to install the following Android SDK packages as some licences have not been accepted.
> platform-tools Android SDK Platform-Tools
patcher;v4 SDK Patch Applier v4
platforms;android-27 Android SDK Platform 27
build-tools;27.0.3 Android SDK Build-Tools 27.0.3
emulator Android Emulator
tools Android SDK Tools


I found the following thread with lots of suggested fixes:

https://stackoverflow.com/q/54273412

So I learned that I have to run

%ANDROID_HOME%/tools/bin/sdkmanager --licenses

It did not work at first because the file /users/MYUSERNAME/.android/repositories.cfg was missing. I created an empty file at that path, ran sdkmanager again and accepted all licenses. However, I still get the same error when building my LibGDX project in IntelliJ.


Here is what I have tried to resolve this issue:

  • Ran sdkmanager --licenses with administrator priviledges
  • Ran sdkmanager --update instead of --licenses
  • Installed the Android command line tools and used that sdkmanager batch file instead
  • Made sure that the %ANDROID_HOME%\licenses folder exists and contains license files
  • Made sure that there is not another Android SDK installed on my machine that I am not aware of - both ANDROID_HOME and ANDROID_SDK_ROOT (I read that the former is outdated) environment variables point to the same folder that is also configured as Android SDK location in the Android Studio SDK Manager and as an Android SDK home path in my IntelliJ project settings
  • Selected the JRE that comes with Android Studio as the standard Java runtime environment on my machine (by setting JAVA_HOME to C:\Program Files\Android\Android Studio\jre)
  • Uninstalled the API 30 SDK that was automatically installed with Android Studio, so I would only have API 27 left
  • Tried using the API 30 SDK instead of API 27 by configuring it in the android\build.gradle file of my LibGDX project
  • Uninstalled Android Studio, removed the SDK folder and reinstalled everything
  • Added yes | sdkmanager --licenses to my gradlew.bat

None of these seemed to help. When I run sdkmanager --licenses again, the response is

> All SDK package licenses accepted.

but IntelliJ keeps saying the opposite.

I am out of ideas how to resolve this. Any help would be highly appreciated.

答案1

得分: 0

问题很可能是由于过时的Gradle版本与其他某些依赖项(可能是Android SDK)不兼容导致的。我通过将项目迁移到最新的LibGDX版本(1.9.11)来解决这个问题。

我的游戏无法在配置了gradle/wrapper/gradle-wrapper.properties中的Gradle包装器(版本5.4.1)下运行,因为我收到了另一个错误消息(“无法打开cp_init重映射类缓存”),所以我切换到了最新的Gradle版本,即本地安装的(6.5.1):设置 -> 构建、执行、部署 -> 构建工具 -> Gradle -> 使用指定位置的Gradle

我还将Android API从30下载到29,因为这是与LibGDX 1.9.11推荐一起使用的版本。然而,我不再需要使用命令行工具来接受许可证。

英文:

The issue was most likely due to an incompatibility of the outdated Gradle version with some other dependency, possibly the Android SDK. I resolved it by migrating my project to the newest LibGDX version (1.9.11).

My game would not run with the Gradle wrapper configured in gradle/wrapper/gradle-wrapper.properties (version 5.4.1) because I got another error message ("Could not open cp_init remapped class cache"), so I switched to the latest Gradle version, which is locally installed (6.5.1): Settings -> Build, Execution, Deployment -> Build Tools -> Gradle -> Use Gradle from: Specified location

I also downloaded the Android API from 30 to 29, as that is the version recommended for use with LibGDX 1.9.11. However, I did not have to use the command line tool to accept the licenses anymore.

huangapple
  • 本文由 发表于 2020年7月25日 23:56:39
  • 转载请务必保留本文链接:https://go.coder-hub.com/63090417.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定