libgdx 项目中的 BaseGameUtils - 找不到构建工具修订版 20.0.0

BaseGameUtils in libgdx Project - Failed to find build tools revision 20.0.0

Gradle 同步失败并显示以下消息:

failed find Build Tools revision 20.0.0

在 Android 工作室中,我从 sdk 管理器安装了 google 播放服务包。我在项目的根目录中创建了一个文件夹库,并在此文件夹中放置了 BaseGameUtils。我修改了行

include 'desktop', 'android', 'core', ':libraries:BaseGameUtils'

在 gradle.settings 文件中。 我还编辑了 build.gradle 文件,它现在看起来像这样:

buildscript {
        repositories {
            mavenCentral()
            maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
        }
        dependencies {
        classpath 'com.android.tools.build:gradle:1.2.3'
    }
}

allprojects {
    apply plugin: "eclipse"
    apply plugin: "idea"

    version = '1.0'
    ext {
       appName = "TapTapSort"
        gdxVersion = '1.6.5'
        roboVMVersion = '1.6.0'
        box2DLightsVersion = '1.4'
        ashleyVersion = '1.6.0'
        aiVersion = '1.5.0'
        gdxUtilsVersion = '0.11.0';
    }

    repositories {
        mavenCentral()
        maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
        maven { url "https://oss.sonatype.org/content/repositories/releases/" }
    }
}

project(":desktop") {
    apply plugin: "java"


    dependencies {
        compile project(":core")
        compile "com.badlogicgames.gdx:gdx-backend-lwjgl:$gdxVersion"
        compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
        compile "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-desktop"
        compile "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-desktop"
    }
}

project(":android") {
    apply plugin: "android"

    configurations { natives }

    dependencies {
        compile project(":core")
        compile "com.badlogicgames.gdx:gdx-backend-android:$gdxVersion"
        natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi"
        natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi-v7a"
        natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86"
        compile "com.badlogicgames.gdx:gdx-box2d:$gdxVersion"
        natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-armeabi"
        natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-armeabi-v7a"
        natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-x86"
        compile "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"
        natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-armeabi"
        natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-armeabi-v7a"
        natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-x86"
        compile "com.google.android.gms:play-services:7.8.0+"
    }
}

project(":core") {
    apply plugin: "java"


    dependencies {
        compile "com.badlogicgames.gdx:gdx:$gdxVersion"
        compile "com.badlogicgames.gdx:gdx-box2d:$gdxVersion"
        compile "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"
        compile "net.dermetfan.libgdx-utils:libgdx-utils:$gdxUtilsVersion"
        compile "net.dermetfan.libgdx-utils:libgdx-utils-box2d:$gdxUtilsVersion" // Box2D module
    }
}

project(":libraries:BaseGameUtils")

tasks.eclipse.doLast {
    delete ".project"
}

build.gradle 的 BaseGameUtils: 应用插件:'com.android.library'

buildscript {
    repositories {
        jcenter()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:1.3.0'
    }
}

dependencies {
    // Set defaults so that BaseGameUtils can be used outside of BasicSamples
    if (!hasProperty('appcompat_library_version')) {
        ext.appcompat_library_version = '20.0.+'
    }
    if (!hasProperty('support_library_version')) {
        ext.support_library_version = '20.0.+'
    }
    if (!hasProperty('gms_library_version')) {
        ext.gms_library_version = '7.8.0'
    }

    compile "com.android.support:appcompat-v7:${appcompat_library_version}"
    compile "com.android.support:support-v4:${support_library_version}"
    compile "com.google.android.gms:play-services-games:${gms_library_version}"
    compile "com.google.android.gms:play-services-plus:${gms_library_version}"
    compile "com.google.android.gms:play-services-appstate:${gms_library_version}"
}

android {
    // Set defaults so that BaseGameUtils can be used outside of BasicSamples
    if (!hasProperty('android_compile_version')) {
        ext.android_compile_version = 20
    }
    if (!hasProperty('android_version')) {
        ext.android_version = '20'
    }

    compileSdkVersion android_compile_version
    buildToolsVersion android_version
}

这是已安装工具的屏幕截图:

您 gradle 安装程序中的构建工具版本需要与您安装的版本相匹配。出于某种原因,您的 SDK 管理器没有显示您当前的构建工具版本,但我假设它是最新的 23.0.0。

build.gradle 目录中的 android 文件中,更改

buildToolsVersion "20.0.0"

buildToolsVersion "23.0.0"

或者也许(不确定这是否有效):

buildToolsVersion "23.0.*"

编辑: 根据您的更新。我现在无法对此进行测试以确定,但我认为 BaseGameUtils 正在寻找您在项目根目录中名为 ext 的块中定义 buildToolsVersioncompileSDKVersion

所以在你的根 build.gradle 的顶部你可以放

ext {
    compileSdkVersion = 23 //or whatever you have installed
    buildToolsVersion = "23.0.0"
}

然后在 android 目录中的 build.gradle 中,更改这两行以引用相同的 ext 块:

android {
    //...
    compileSdkVersion = ext.compileSdkVersion
    buildToolsVersion = ext.buildToolsVersion
    //...
}

不确定,但您可能需要将 ext. 替换为 rootProject.ext.。也许还可以在 BaseGameUtil 的 build.gradle.

中更改它