升级 libGdx 和 Gradle 项目导致构建错误

Upgrading libGdx and Gradle project results in build errors

我有一个使用版本 1.9.1 和 Gradle 2.4 的旧 libGdx 项目。我试过升级到 libGdx 1.9.11 和 Gradle 6.5。但是我收到以下构建错误:

Gradle sync failed: Could not find org.jetbrains.trove4j:trove4j:20160824. Searched in the following locations: - https://repo.maven.apache.org/maven2/org/jetbrains/trove4j/trove4j/20160824/trove4j-20160824.pom - https://oss.sonatype.org/content/repositories/snapshots/org/jetbrains/trove4j/trove4j/20160824/trove4j-20160824.pom - https://dl.google.com/dl/android/maven2/org/jetbrains/trove4j/trove4j/20160824/trove4j-20160824.pom Required by: project : > com.android.tools.build:gradle:4.1.1 > com.android.tools.build:builder:4.1.1 > com.android.tools:sdk-common:27.1.1

我该如何解决?

在根 build.gradle 文件中添加 jcenter()

repositories {
        jcenter()   // <- Add this
        mavenLocal()
        mavenCentral()
        maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
        maven { url "https://oss.sonatype.org/content/repositories/releases/" }
        google()
    }

然后将您的项目与 gradle 文件同步。请确保 gradle 未处于离线模式并且您的网络连接良好。