【发布时间】:2014-04-29 04:52:12
【问题描述】:
我正在尝试添加一个外部库。我在项目文件夹下的 a/libs 文件夹中创建,并在我的 gradle.build 文件中有以下代码。但它根本不同步。
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.9.+'
}
}
allprojects {
repositories {
mavenCentral()
flatDir {
dirs 'libs'
}
}
}
dependencies {
compile 'com.radiusnetworks:AndroidIBeaconLibrary:0.7.1@aar'
}
我得到的错误是:
Gradle 'BLE_Client' 项目刷新失败:
构建脚本错误,发现不受支持的 Gradle DSL 方法:'compile()'!
可能的原因可能是:
- 您正在使用该方法不存在的 Gradle 版本
- 您没有应用提供该方法的 Gradle 插件
- 或者构建脚本中有错误
【问题讨论】:
-
这看起来像是根,
build.gradle文件基于文件 cmets...dependencies宏不应该在buildscript或allprojects闭包下吗? -
我已经尝试了这两种方法 - 在 buildscript 中添加 allProjects 和 dependencies 宏。它仍然给出错误:没有方法签名:org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.compile() 适用于参数类型:(java.lang.String) 值:[com.radiusnetworks: AndroidIBeaconLibrary:0.7.1@aar] 可能的解决方案:module(java.lang.Object)
-
下一个猜测是根 build.gradle 文件对 android 和 AARs 一无所知,当 android-plugin 是已知的东西时,将其应用于应用程序 build.gradle 文件。
标签: android android-studio android-gradle-plugin build.gradle