目录

我的学习分享

记录精彩的程序人生

gradle项目提示grable版本低org.gradle.tooling.UnsupportedVersionException|failed to find target android-20

Failed to load the build script of the project(s):
org.gradle.tooling.UnsupportedVersionException: Support for builds using Gradle versions older than 2.6 was removed in tooling API version 5.0. You are currently using Gradle version 2.3. You should upgrade your Gradle build to use Gradle 2.6 or later.

打开项目目录-》gradle-》wrapper->gradle-wrapper.properties文件:

#Sat Sep 21 13:08:26 CEST 2013
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=http\://services.gradle.org/distributions/gradle-2.6-all.zip

最后一行2.6是版本号,将其改为合适的版本即可


Failed to load the build script of the project(s):
org.gradle.tooling.BuildException: Could not run build action using Gradle distribution 'http://services.gradle.org/distributions/gradle-2.6-all.zip'.
org.gradle.internal.exceptions.LocationAwareException: A problem occurred configuring project ':android'.
org.gradle.api.ProjectConfigurationException: A problem occurred configuring project ':android'.
java.lang.IllegalStateException: failed to find target android-20 : D:\Android\sdk

打开android项目下的build.gradle文件:

android {
    buildToolsVersion "25.0.0"
    compileSdkVersion 21
    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src']
            resources.srcDirs = ['src']
            aidl.srcDirs = ['src']
            renderscript.srcDirs = ['src']
            res.srcDirs = ['res']
            assets.srcDirs = ['assets']
        }

        instrumentTest.setRoot('tests')
    }
}

开头两行buildtoolsVersioncompileSdkVersion调整为合适的值