我正在研究一个包含两个Android库项目的项目。当我将这些库上传到我的Maven回购库(Nexus)时,生成的pom在依赖项中不包含<type>aar</type>
元素。Android库项目瞬态依赖松散AAR类型
这里是我的依赖关系树
* App1
\
* lib1
|\
| * lib2
* Other libs
您可以将这个图,我app
取决于lib1
,这取决于lib2
中看到的。这两个库都是Android库项目,因此是AAR。
LIB1 /的build.gradle
apply plugin: 'com.android.library'
apply from: 'https://raw.github.com/chrisbanes/gradle-mvn-push/master/gradle-mvn-push.gradle'
android {
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion
defaultConfig {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion 20
versionCode 1
versionName "1.0"
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
provided project(':lib2')
compile 'com.squareup.picasso:picasso:2.3.3'
}
LIB2 /的build.gradle
apply plugin: 'com.android.library'
apply from: 'https://raw.github.com/chrisbanes/gradle-mvn-push/master/gradle-mvn-push.gradle'
android {
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion
defaultConfig {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion 19
versionCode 1
versionName '1.0'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:19.+'
compile 'com.squareup.retrofit:retrofit:1.6.1'
compile 'com.squareup.okhttp:okhttp-urlconnection:2.0.0'
compile 'com.squareup.okhttp:okhttp:2.0.0'
}
通知如何Lib1
包括Lib2
作为project()
依赖性。
现在,当我使用Chris Banes的优秀gradle-mvn-push插件部署时,一切都按预期工作。在生成的pom.xml中我只注意到一个奇怪的地方。
<dependencies>
<dependency>
<groupId>com.example</groupId>
<artifactId>lib2</artifactId>
<version>0.0.1-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
...
</dependencies>
注意,mavenDeployer插件在依赖留出了<type>aar</type>
元件时,它产生的POM。
在我的应用程序的项目(这是一个Maven项目),我有这样的依赖上市:
<dependencies>
<dependency>
<groupId>com.example</groupId>
<artifactId>lib1</artifactId>
<version>0.0.1-SNAPSHOT</version>
<type>aar</type>
</dependency>
...
</dependencies>
当试图用Maven构建这个,我得到以下错误。
Could not resolve dependencies for project com.example:app:apk:1.0.0-SNAPSHOT: The following artifacts could not be resolved: com.example:lib2:jar:0.0.1-SNAPSHOT
注意它是如何寻找jar版本的库。我相信,由于mavenDeployer插件没有在生成的pom的依赖列表中生成<type>aar</type>
,因此maven默认寻找jar。
有谁知道如何构建Android库项目,其中包括与Gradle的临时依赖项?
同样的问题在这里。 – sarfata 2014-10-10 01:41:37