同步Gradle会出现以下错误 错误:(24,0)未找到Gradle DSL方法:' main()' 可能的原因:
" gradle.build"
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.0'
}
}
apply plugin: 'com.android.library'
android {
compileSdkVersion 23
buildToolsVersion "21.1.2"
defaultConfig {
minSdkVersion 15
targetSdkVersion 23
}
}
sourceSets.main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
res.srcDirs = ['res']
jniLibs.srcDirs = ['libs']
}
答案 0 :(得分:1)
您必须在sourceSets
块
android
块
android {
compileSdkVersion 23
buildToolsVersion "21.1.2"
defaultConfig {
minSdkVersion 15
targetSdkVersion 23
}
sourceSets.main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
res.srcDirs = ['res']
jniLibs.srcDirs = ['libs']
}
}
答案 1 :(得分:0)
如果您使用的是gradle插件版本0.14.0
或更高版本,则应将runProguard
替换为minifyEnabled
文件中的build.gradle
。