我是 android 开发的初学者,目前我真的坚持实施 actionbarsherlock。我知道这之前已经讨论过,但是我对依赖关系以及如何设置项目结构感到非常困惑。我尝试按照所有说明进行操作,但没有成功。我一直在使用 gradle 遇到不同的问题。我正在使用 Android Studio 0.2.0。
我当前的错误说:
>Gradle 'MyAppProject' project refresh failed:
>Could not fetch model of type 'IdeaProject' using Gradle distribution "http://services.gradle.org/distributions/gradle-1.6-bin.zip".
>Error: Gradle: A problem occurred configuring project ':MyApp'.
>Failed to notify project evaluation listener.
>A problem occurred configuring project ':Libraries:ActionBarSherlock'.
>Failed to notify project evaluation listener.
>Main Manifest missing from C:\Users\JJ2\AndroidStudioProjects\MyAppProject\Libraries\ActionBarSherlock\src\main\AndroidManifest.xml
我的项目构建如下:
-MyAppProject
|+.idea
|+gradle
|-Libraries
||-ActionBarSherlock
|||+gen
|||+libs
|||+res
|||-src
||||-android.support.v4.app
|||||-Watson
||||+com.actionbarsherlock
|||-ActionBarSherlock.iml
|||-AndroidManifest.xml
|||-build.gradle
|||-lint.xml
|||-pom.xml
|||-project.properties
|||-README.md
|-MyApp
||+build
||+libs
||-src
|||-main
||||-java
|||||+com.mywebsite.myapp
||||+res
||||-AndroidManifest.xml
||||-ic_launcher-web.png
||-build.gradle
||-MyApp.iml
|-build.gradle
|-gradlew
|-gradlew.bat
|-local.properties
|-settings.gradle
|-MyAppProject.iml
-External Libraries
|-<Android 4.2.2>
||+android.jar
||+annotations.jar
||+res
MyAppProject 目录下 build.gradle 的内容:
task assemble{}
MyApp 目录下的 build.gradle:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.0'
}
}
apply plugin: 'android'
dependencies {
compile project(":Libraries:ActionBarSherlock")
}
android {
compileSdkVersion 17
buildToolsVersion "17.0.0"
defaultConfig {
minSdkVersion 9
targetSdkVersion 17
}
}
以及 Libraries\ActionBarSherlock 目录中的 build.gradle:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.0'
}
}
apply plugin: 'android-library'
dependencies {
compile files('libs/android-support-v4.jar')
}
android {
compileSdkVersion 17
buildToolsVersion "17.0.0"
defaultConfig {
minSdkVersion 9
targetSdkVersion 17
}
}
最后,我的项目结构如下所示:
模块
-ActionBarSherlock (Dependencies: Android 4.2.2, [v]android-support-v4)
-Android
-MyApp (Dependencies: Android 4.2.2, [ ]ActionBarSherlock)
-Android
-Android-Gradle
-MyAppProject (Dependencies: Android 4.2.2)
-Android-Gradle
图书馆
None
全球图书馆
-android-support-v4 (Classes: ...\MyAppProject\MyApp\libs\android-support-v4.jar)
我希望有人能注意到代码有什么问题,尽管自新的 Android Studio 发布以来,很多人似乎已经解决了问题。提前致谢!