我正在尝试使用gradle构建工具构建一个简单的Android应用程序。但我得到这样的错误
没有方法签名:org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.compile()适用于参数类型:(java.lang.String)values:[org.gradle.api.plugins :gradle这个-Android的插件:1.2.0-快照] 可能的解决方案:module(java.lang.Object)
这里是build.gradle的简单配置
buildscript {
repositories {
mavenCentral()
}
dependencies {
compile 'org.gradle.api.plugins:gradle-android-plugin:1.2.0-SNAPSHOT'
}
}
apply plugin: 'android'
repositories {
mavenCentral()
}
processResource {
expand (project.properties)
}
task configureDebug << {
jar.classifier = "debug"
}
task configureRelease << {
proguard.enabled = true
}
答案 0 :(得分:1)
在应用插件时,您需要告诉您构建脚本以在其类路径中使用它。编译时不需要它,因此只需将配置compile
更改为classpath
即可。更多信息,请参阅Gradle用户指南中的51.5.1. Using your plugin in another project。
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'org.gradle.api.plugins:gradle-android-plugin:1.2.0-SNAPSHOT'
}
}
编辑:目前该插件不支持Android SDK的r20。有关详细信息,请参阅此issue。
答案 1 :(得分:1)
确保在应用程序build.gradle&#34; YourProjectName-&gt; yourprojectname-&gt; build.gradle&#34;上编写依赖关系块。在android studio层次结构中。
答案 2 :(得分:0)
使用android gradle tools
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.4'
}