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

时间:2015-09-17 07:01:06

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

Gradle sync失败,并显示以下消息:

failed find Build Tools revision 20.0.0

在Android工作室,我已经从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
}

以下是已安装工具的屏幕截图: enter image description here

1 个答案:

答案 0 :(得分:2)

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

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

buildToolsVersion "20.0.0"

buildToolsVersion "23.0.0"

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

buildToolsVersion "23.0.*"

修改 根据您的更新。我现在无法对此进行测试,但我认为BaseGameUtils正在寻找您在项目中名为buildToolsVersion的块中定义compileSDKVersionext' s root。

所以在root的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中更改它。