Gradle error “Cannot invoke method buildToolsVersion() on null object”… here is a solution to the problem.
Gradle error “Cannot invoke method buildToolsVersion() on null object”
I need some help….
I’m getting this error when trying to build android .apk
:
FAILURE: Build Failed with an exception. "Cannot invoke method buildToolsVersion() on null object"
I’m building on Windows via cmd.exe using commands: gradle build
from gonative.io source code.
Here is my build.gradle file:
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.+'
}
Can someone help me?
Thank you in advance for your help,
Ivan
Solution
CommonsWare’s answer solves the problem. Moving buildToolsVersion
to the next line solved the problem. Sorry Mark, this is really a super rookie question. This should be the build.gradle file:
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.+'
}