Gradle Error"无法在null对象上调用方法buildToolsVersion()"

时间:2015-08-07 16:41:04

标签: java android gradle invoke build-tools

我需要一些帮助...

我在尝试构建android .apk时遇到此错误:

FAILURE: Build Failed with an exception. "Cannot invoke method buildToolsVersion() on null object"

我通过cmd.exe构建Windows,命令为:gradle build来自gonative.io源代码。

这是我的build.gradle文件:

apply plugin: 'android'

android {
compileSdkVersion 21    buildToolsVersion "21.1.2"

defaultConfig {
    minSdkVersion 14
    targetSdkVersion 21
    applicationId "io.gonative.android.xeeyk"
    versionCode 13
}

signingConfigs {
    release {
        storeFile file("../../release.keystore")
        storePassword "password"
        keyAlias "release"
        keyPassword "password"
    }
}

buildTypes {
    debug {
    applicationIdSuffix ".debug"
    }
    release {
        minifyEnabled true
        proguardFiles getDefaultProguardFile('proguard-android.txt'),     'proguard-project.txt'
        zipAlignEnabled true
        signingConfig signingConfigs.release
        }
    }
}

dependencies {
compile 'com.android.support:support-v4:21.+'
compile 'com.android.support:appcompat-v7:21.0.+'
compile 'com.google.android.gms:play-services:6.1.+'
}

有人能帮助我吗? 在此先感谢任何帮助, 伊万

1 个答案:

答案 0 :(得分:3)

CommonsWare回答这个伎俩。移动buildToolsVersion到下一行解决了问题。对不起马克,这真的是一个超级的菜鸟问题。这应该是build.gradle文件:

apply plugin: 'android'

android {
compileSdkVersion 21    
buildToolsVersion "21.1.2"

defaultConfig {
minSdkVersion 14
targetSdkVersion 21
applicationId "io.gonative.android.xeeyk"
versionCode 13
}

signingConfigs {
release {
    storeFile file("../../release.keystore")
    storePassword "password"
    keyAlias "release"
    keyPassword "password"
    }
}

buildTypes {
debug {
applicationIdSuffix ".debug"
}
release {
    minifyEnabled true
    proguardFiles getDefaultProguardFile('proguard-android.txt'),     'proguard-project.txt'
    zipAlignEnabled true
    signingConfig signingConfigs.release
        }
    }
}

dependencies {
compile 'com.android.support:support-v4:21.+'
compile 'com.android.support:appcompat-v7:21.0.+'
compile 'com.google.android.gms:play-services:6.1.+'
}