【问题标题】:BaseGameUtils in libgdx Project - Failed to find build tools revision 20.0.0libgdx 项目中的 BaseGameUtils - 找不到构建工具修订版 20.0.0
【发布时间】:2015-09-17 07:01:06
【问题描述】:

Gradle 同步失败并出现以下消息:

failed find Build Tools revision 20.0.0

在 Android Studio 中,我从 sdk 管理器安装了 google play 服务包。我在项目的根目录中创建了一个文件夹库,并在这个文件夹中放置了 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"
}

BaseGameUtils 的 build.gradle: 应用插件:'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
}

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

【问题讨论】:

    标签: android-studio libgdx google-play-services android-gradle-plugin


    【解决方案1】:

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

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

    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 中更改它。

    【讨论】:

    • 已经配置好了。我修改了这篇文章,添加了BaseGameUtils的build.gradle,我觉得问题可以在那里找到?
    • 我认为 baseGameUtils 的 gradle 文件正在您项目的根目录 build.gradle 中寻找 ext 块。一种定义 android buildToolsVersion 和 compileSDK 版本。见编辑。
    猜你喜欢
    • 2016-04-27
    • 2021-07-31
    • 2020-12-22
    • 2016-08-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-05-13
    相关资源
    最近更新 更多