我有一个android-library插件,它使用几个包含.jar文件的android库,并直接从我的build.gradle文件中引用:
compile fileTree(dir: 'libs', include: '*.jar')
然后我会发出一个gradlew assembleRelease
命令来创建一个可以在Android应用程序中使用的.aar文件。到目前为止,这对我来说一直很好。
我现在需要在我的android-library中使用Google Play服务。正如官方Android文档(http://developer.android.com/google/play-services/setup.html#Setup)中所述,我需要通过从maven导入Google Play服务作为库项目:
compile 'com.google.android.gms:play-services:4.3.23'
但是,当我构建我的.aar文件时,Google Play服务似乎不包含在其中(我的.aar文件只有200kb,Google Play Services .jar库大于1mb)。
我已经读过Google Play服务应该被引用为Android库模块,但我无法在没有编译错误的情况下将其导入。有人可以帮我把Google Play服务打包到我的android-library中吗?
我的android-library build.gradle文件:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.6.+'
}
}
apply plugin: 'android-library'
repositories {
mavenCentral()
}
dependencies {
compile 'com.google.android.gms:play-services:4.3.23'
compile fileTree(dir: 'libs', include: '*.jar')
}
android {
compileSdkVersion 19
buildToolsVersion '19.0.1'
defaultConfig {
minSdkVersion 9
targetSdkVersion 19
}
release {
runProguard false
}
}
我的android应用程序build.gradle文件:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.6.+'
}
}
apply plugin: 'android'
repositories {
mavenCentral()
flatDir {
dirs 'libs'
}
}
android {
compileSdkVersion 19
buildToolsVersion "19.0.1"
defaultConfig {
minSdkVersion 9
targetSdkVersion 19
}
buildTypes {
release {
runProguard true
proguardFile getDefaultProguardFile('proguard-android-optimize.txt')
}
}
productFlavors {
defaultFlavor {
proguardFile 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:appcompat-v7:+'
compile 'novom.anyware.anywaresdk:anywaresdk:0.1.0@aar'
}
从我的主模块的根目录发出gradle dependencies
时,这是我的结果:
Relying on packaging to define the extension of the main artifact has been depre
cated and is scheduled to be removed in Gradle 2.0
:MyOldApp:dependencies
------------------------------------------------------------
Project :MyOldApp
------------------------------------------------------------
_DefaultFlavorDebugApk
+--- com.android.support:appcompat-v7:+ -> 19.1.0
| \--- com.android.support:support-v4:19.1.0
\--- novom.anyware.anywaresdk:anywaresdk:0.1.0
_DefaultFlavorDebugCompile
+--- com.android.support:appcompat-v7:+ -> 19.1.0
| \--- com.android.support:support-v4:19.1.0
\--- novom.anyware.anywaresdk:anywaresdk:0.1.0
_DefaultFlavorReleaseApk
+--- com.android.support:appcompat-v7:+ -> 19.1.0
| \--- com.android.support:support-v4:19.1.0
\--- novom.anyware.anywaresdk:anywaresdk:0.1.0
_DefaultFlavorReleaseCompile
+--- com.android.support:appcompat-v7:+ -> 19.1.0
| \--- com.android.support:support-v4:19.1.0
\--- novom.anyware.anywaresdk:anywaresdk:0.1.0
_DefaultFlavorTestApk
No dependencies
_DefaultFlavorTestCompile
No dependencies
apk - Classpath packaged with the compiled main classes.
+--- com.android.support:appcompat-v7:+ -> 19.1.0
| \--- com.android.support:support-v4:19.1.0
\--- novom.anyware.anywaresdk:anywaresdk:0.1.0
archives - Configuration for archive artifacts.
No dependencies
compile - Classpath for compiling the main sources.
+--- com.android.support:appcompat-v7:+ -> 19.1.0
| \--- com.android.support:support-v4:19.1.0
\--- novom.anyware.anywaresdk:anywaresdk:0.1.0
debugApk - Classpath packaged with the compiled debug classes.
No dependencies
debugCompile - Classpath for compiling the debug sources.
No dependencies
default - Configuration for default artifacts.
No dependencies
defaultFlavorApk - Classpath packaged with the compiled defaultFlavor classes.
No dependencies
defaultFlavorCompile - Classpath for compiling the defaultFlavor sources.
No dependencies
instrumentTestApk - Classpath packaged with the compiled instrumentTest classes.
No dependencies
instrumentTestCompile - Classpath for compiling the instrumentTest sources.
No dependencies
instrumentTestDefaultFlavorApk - Classpath packaged with the compiled instrument
TestDefaultFlavor classes.
No dependencies
instrumentTestDefaultFlavorCompile - Classpath for compiling the instrumentTestD
efaultFlavor sources.
No dependencies
releaseApk - Classpath packaged with the compiled release classes.
No dependencies
releaseCompile - Classpath for compiling the release sources.
No dependencies
BUILD SUCCESSFUL
Total time: 7.388 secs