gpt4 book ai didi

android - 如何在Android项目中使用gradle进行依赖

转载 作者:行者123 更新时间:2023-12-03 04:44:50 30 4
gpt4 key购买 nike

项目A:Actionbarsherlock
项目B:SlidingMenu
项目C:myAPP

A是B和C的图书馆项目;
B是C的图书馆项目;

那么如何编写build.gradle和settings.gradle。

以下是我的文件:
一个Actionbarsherlock:build gradle

buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.4.2'
}
}

apply plugin: 'android-library'



android {
compileSdkVersion 17
buildToolsVersion "17"

defaultConfig {
minSdkVersion 8
targetSdkVersion 17
}
dependencies {
compile group: 'com.google.android', name: 'support-v4', version: 'r7'
}
sourceSets {
main {
manifest {
srcFile 'AndroidManifest.xml'
}
java {
srcDir 'src'
}
res {
srcDir 'res'
}
assets {
srcDir 'assets'
}
resources {
srcDir 'src'
}
aidl {
srcDir 'src'
}
}
}
}

这是B SlidingMenu的build.gradle:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.4.2'
}
}

apply plugin: 'android-library'

android {
compileSdkVersion 17
buildToolsVersion "17"

defaultConfig {
minSdkVersion 8
targetSdkVersion 17
}
dependencies {
compile project(":actionbarsherlock")
compile group: 'com.google.android', name: 'support-v4', version: 'r7'
}
sourceSets {
main {
manifest {
srcFile 'AndroidManifest.xml'
}
java {
srcDir 'src'
}
res {
srcDir 'res'
}
assets {
srcDir 'assets'
}
resources {
srcDir 'src'
}
aidl {
srcDir 'src'
}
}
}
}

这是C myAPP build.gradle
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.4.2'
}
}

apply plugin: 'android'

android {
compileSdkVersion 17
buildToolsVersion "17"

defaultConfig {
minSdkVersion 8
targetSdkVersion 17
}
dependencies {
compile project(":actionbarsherlock")
compile project(":SlidingMenu")
}
sourceSets {
main {
manifest {
srcFile 'AndroidManifest.xml'
}
java {
srcDir 'src'
}
res {
srcDir 'res'
}
assets {
srcDir 'assets'
}
resources {
srcDir 'src'
}
aidl {
srcDir 'src'
}
}
}

}

这是Project build.gradle
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.4.2'
}
}

allprojects {
repositories {
mavenCentral()
}
}

和settings.gradle
include 'actionbarsherlock'
include 'SlidingMenu'
include 'YueClient'

最佳答案

可能无关

现在,您可以使用com.android.support:support-v4:13.0.+来获取兼容的操作栏,而不是Sherlock。

在此处查看完整文档http://developer.android.com/reference/android/support/v7/app/ActionBarActivity.html

关于android - 如何在Android项目中使用gradle进行依赖,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17401928/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com