gpt4 book ai didi

java - Gradle 错误 "Cannot invoke method buildToolsVersion() on null object"

转载 作者:太空宇宙 更新时间:2023-11-03 13:54:04 25 4
gpt4 key购买 nike

我需要一些帮助...

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

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

我正在通过 cmd.exe 使用命令在 Windows 上构建:来自 gonative.io 源代码的 gradle build

这是我的 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.+'
}

有人可以帮助我吗?在此先感谢您的帮助,伊万

最佳答案

CommonsWare 的回答可以解决问题。将 buildToolsVersion 移动到下一行解决了问题。对不起马克,这真的是一个 super 菜鸟问题。这应该是 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.+'
}

关于java - Gradle 错误 "Cannot invoke method buildToolsVersion() on null object",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31882749/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com