作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我已经尝试了很多来解决这个问题。我正在尝试使用 gradle 从命令行构建我的 android 应用程序,但出现以下错误
A problem occurred evaluating root project 'android-build'.
> Could not find method android() for arguments [build_bumi6pcyg9xxwmbnm52kyqutw$_run_closure1@6ba7383d] on root project 'android-build'.
buildscript {
repositories {
maven {
url "http://repo1.maven.org/maven2"
}
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.3'
}
}
android {
compileSdkVersion 23
buildToolsVersion "21.1.2"
def versionPropsFile = file('version.properties')
if (versionPropsFile.canRead()) {
def Properties versionProps = new Properties()
versionProps.load(new FileInputStream(versionPropsFile))
def code = versionProps['VERSION_CODE'].toInteger() + 1
versionProps['VERSION_CODE']=code.toString()
versionProps.store(versionPropsFile.newWriter(), null)
defaultConfig {
versionCode code
versionName "1.1"
minSdkVersion 14
targetSdkVersion 18
}
}
else {
throw new GradleException("Could not read version.properties!")
}
}
最佳答案
您需要在模块 build.gradle 文件的第一行添加此配置:
apply plugin: 'com.android.application'
The first line in the build configuration applies the Android plugin for Gradle to this build and makes the android {} block available to specify Android-specific build options.
关于android - Gradle 错误 : Could not find method android(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39985471/
我是一名优秀的程序员,十分优秀!