Com*_*are 29 android android-gradle-plugin
关于Gradle中AAR文件的传递依赖性,有几个问题浮出水面:
我也遇到类似的问题,试图在远程存储库中的AAR文件上设置传递依赖.我有App A,取决于库B,而库B又依赖于库C.库C在Maven仓库中.库B在同一个仓库中,其中POM包含对库C的依赖性.应用程序A在其依赖项中具有库B. 但是,运行gradle clean assembleDebug结果为:"模块版本[库B]依赖于库,但不是库本身".
我试着给其中一个问题一个赏金,希望清楚,没有运气.
我的猜测是,我和那些有上述SO问题的人有两种可能的困难来源:
来自远程存储库的传递AAR依赖性简单地被破坏
来自远程存储库的传递AAR依赖项可以工作,但是我们的POM文件,build.gradle文件或某些破坏依赖项的内容有所不同
问题:有没有人知道某个公共存储库(例如,Maven Central)中的AAR工件,它依赖于另一个AAR工件,也在同一个公共存储库中?
我对依赖于本地存储库中的某些内容的AAR不感兴趣,例如依赖于Maven Central中的AAR com.android.support:support-v4.在我的例子中,如果库B和库C都在我的本地Maven存储库(~/.m2)中,一切正常.
据Xav说,我在做什么应该有效.因此,我希望有人可以指出一个有效的例子,这样我就可以用它来确定我们其他人可能出错的地方.
注意:我知道要求异地资源是禁止的.在这种情况下,我不是自己寻找资源,而是作为工作配置的示例,帮助调试非工作配置.如果您有另一种方式来编写显示工作配置的答案,那就太棒了!
谢谢!
我没有公开示例,但我已在内部托管的Nexus存储库中成功设置了此方案.这是设置:
App - Android应用程序项目LibraryB - Android库项目picasso - 来自Square的开源库(可在Maven Central上获得)LibraryA - Android库项目
应用依赖于LibraryB和毕加索LibraryB依赖于LibraryA
这是LibraryB的POM(从Nexus下载)
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>LibraryB</artifactId>
<version>0.1</version>
<packaging>aar</packaging>
<dependencies>
<dependency>
<groupId>com.example</groupId>
<artifactId>LibraryA</artifactId>
<version>3.0.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.squareup.picasso</groupId>
<artifactId>picasso</artifactId>
<version>2.1.1</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>
Run Code Online (Sandbox Code Playgroud)
这是LibraryB的build.gradle
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.6.+'
}
}
apply plugin: 'android-library'
apply plugin: 'maven'
version versionProp
group 'com.example'
repositories {
mavenCentral()
maven {
url(exampleReleaseRepoUrl)
}
}
android {
compileSdkVersion 19
buildToolsVersion "19.0.0"
defaultConfig {
minSdkVersion 8
targetSdkVersion 19
}
release {
runProguard false
proguardFile 'proguard-rules.txt'
proguardFile getDefaultProguardFile('proguard-android.txt')
}
}
dependencies {
compile 'com.example:LibraryA:3.0.1'
compile 'com.squareup.picasso:picasso:2.1.1'
}
uploadArchives {
repositories {
mavenDeployer {
repository(url: uri(exampleReleaseRepoUrl)) {
authentication(userName: nexusUsername, password: nexusPassword)
}
snapshotRepository(url: uri(exampleSnapshotRepoUrl)) {
authentication(userName: nexusUsername, password: nexusPassword)
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
这是LibraryA的POM(从Nexus下载)
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>LibraryA</artifactId>
<version>3.0.1</version>
<packaging>aar</packaging>
<dependencies>
<dependency>
<groupId>com.android.support</groupId>
<artifactId>support-v4</artifactId>
<version>19.0.0</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>
Run Code Online (Sandbox Code Playgroud)
LibraryA的build.gradle与上面的LibraryB非常相似.
通过以下Gradle命令上载LibraryA和LibraryB的工件和POM
gradle uploadArchives
Run Code Online (Sandbox Code Playgroud)
App的build.gradle看起来像这样
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.6.+'
}
}
apply plugin: 'android'
repositories {
mavenCentral()
maven {
url(exampleReleaseRepoUrl)
}
}
android {
compileSdkVersion 19
buildToolsVersion "19.0.0"
defaultConfig {
minSdkVersion 8
targetSdkVersion 19
}
buildTypes {
release {
runProguard false
proguardFile getDefaultProguardFile('proguard-android.txt')
}
}
productFlavors {
defaultFlavor {
proguardFile 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:support-v4:19.0.0'
compile 'com.android.support:appcompat-v7:19.0.0'
compile 'com.example:LibraryB:0.1'
}
Run Code Online (Sandbox Code Playgroud)
如果您需要任何进一步的信息,请告诉我.
| 归档时间: |
|
| 查看次数: |
4930 次 |
| 最近记录: |