多项目的设置与摇篮为Android [英] Multi-project setup with Gradle for Android
问题描述
我有一个问题让我的Android应用程序的构建。
I am having a problem to make my Android application build.
我有一个主要应用模块,以及需要对谷歌的播放,services_lib另一个。
I have one Main application module, and another one that is needed for the google-play-services_lib.
我的文件夹结构如下:
ParkingApp
|
|-----> google-play-services_lib (Library Project)
|-----> ParkingApp
|-----> settings.gradle
我settings.gradle文件如下:
My settings.gradle file is as follows:
include ':ParkingApp', ':google-play-services_lib'
我ParkingApp具有以下的build.gradle。
My ParkingApp has the following build.gradle.
buildscript {
repositories {
maven { url 'http://repo1.maven.org/maven2' }
}
dependencies {
classpath 'com.android.tools.build:gradle:0.4'
}
}
apply plugin: 'android'
dependencies {
compile files('libs/android-support-v4.jar')
compile project(':google-play-services_lib')
}
android {
compileSdkVersion 17
buildToolsVersion "17.0.0"
defaultConfig {
minSdkVersion 15
targetSdkVersion 17
}
}
和谷歌的播放,services_lib具有以下的build.gradle:
And the google-play-services_lib has the following build.gradle:
buildscript {
repositories {
maven { url 'http://repo1.maven.org/maven2' }
}
dependencies {
classpath 'com.android.tools.build:gradle:0.4'
}
}
apply plugin: 'android-library'
dependencies {
compile files('libs/google-play-services.jar')
}
android {
compileSdkVersion 17
buildToolsVersion "17.0.0"
defaultConfig {
minSdkVersion 15
targetSdkVersion 17
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
res.srcDirs = ['res']
}
}
}
任何帮助AP preciated!
Any help is appreciated!
推荐答案
随着Android的Studio和摇篮新的更新,我想添加支持包和谷歌播放服务罐一个更好的解决方案是使用Maven仓库,而不是加入库它的自我,这里是你如何能既给任何.gradle文件添加,使用这种方式,您将不会有更多的问题将既取决于项目。
With the new updates in Android Studio and Gradle, I think a better solution for adding support package and google play services jars is to use the maven repositories instead of adding the library it self, here is how you can add both to any .gradle file, using this way you will no have more problems adding both to dependent projects.
dependencies {
compile 'com.google.android.gms:play-services:3.1.36'
compile 'com.android.support:support-v4:13.0.+'
}
请注意:在Android 0.2.0工作室的新版本,你也需要更新gradle这个verison为:
Note: In the new version of Android Studio 0.2.0, you will need also to update the gradle verison to:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.+'
}
}
这篇关于多项目的设置与摇篮为Android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!