因此,我正在努力使用 Gradle v1.6 在 Android Studio v0.2 中设置一个非常简单的项目。我想创建一个使用 ActionBarSherlock 的简单应用程序,所以我在 Android Studio 中创建了一个项目。
在创建项目的同一根文件夹中,我下载了最新的 ABS。
所以这是我的结构:
|ABSAppProject
|..settings.gradle
|..build.gradle
|--ABSApp
|....build.gradle
|actionbarsherlock
|..build.gradle
在根目录settings.gradle
中,我有:
include ':ABSApp'
include 'actionbarsherlock'
project(':actionbarsherlock').projectDir=new File('actionbarsherlock')
在actionbarsherlock/build.gradle
我有:
apply plugin: 'android-library'
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.+'
}
}
dependencies {
compile 'com.google.android:support-v4:r7'
}
android {
compileSdkVersion 14
buildToolsVersion '17'
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
res.srcDirs = ['res']
}
}
}
最后ABSApp/build.gradle
,我有:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.+'
}
}
apply plugin: 'android'
repositories {
mavenCentral()
}
dependencies {
compile 'com.android.support:support-v4:r7'
compile project (':actionbarsherlock')
}
android {
compileSdkVersion 17
buildToolsVersion "17.0.0"
defaultConfig {
minSdkVersion 9
targetSdkVersion 16
}
}
根 build.gradle 为空。
构建时,(使用 gradle build --info)我得到:
Starting Build
Settings evaluated using settings file '/Users/m/Documents/Projects/ABSAppProject/settings.gradle'.
Projects loaded. Root project using build file '/Users/ma/Documents/Projects/ABSAppProject/build.gradle'.
Included projects: [root project 'ABSAppProject', project ':ABSApp', project ':actionbarsherlock']
Evaluating root project 'ABSAppProject' using build file '/Users/m/Documents/Projects/ABSAppProject/build.gradle'.
Evaluating project ':ABSApp' using build file '/Users/m/Documents/Projects/ABSAppProject/ABSApp/build.gradle'.
Evaluating project ':actionbarsherlock' using empty build file.
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':ABSApp'.
> Failed to notify project evaluation listener.
> Configuration with name 'default' not found.
使用 Gradle 单独构建 ABS 库似乎可以正常工作,因此 gradle.build 文件可能还可以。
我究竟做错了什么?