简体   繁体   English

嵌套的aar依赖项不起作用

[英]Nested aar dependencies not working

To simplify things I'm going to call the libraries I'm using library_a.aar and library_b.aar. 为简化起见,我将使用library_a.aar和library_b.aar来调用库。

Here is the scenario that I'm facing. 这是我面临的情况。 library_a is build and pushed to maven_repository and no problems here. library_a已构建并推送到maven_repository,在这里没有问题。 library_b depends on library_a and added to library_b as follows: library_b取决于library_a,并添加到library_b中,如下所示:

repositories {
    maven {
        credentials {
            username USERNAME
            password PASSWORD
        }
        url "https://api.bitbucket.org/1.0/repositories/COMPANY/maven_repository/raw/releases"
    }
}

dependencies {
    ...
    compile 'package:library_a:1.0'
    ...
}

library_b is built with no errors and uploaded to the maven_repository. library_b的构建没有错误,并且已上载到maven_repository。

Now my application depends on library_b which I need to add by providing (as above) the repository along with the credentials. 现在,我的应用程序依赖于library_b,我需要通过提供(如上所述)存储库以及凭据来添加该文件。

The first issue that I'm facing is that in order to compile library_b in my project it needs to be compiled in the following way: 我面临的第一个问题是,要在我的项目中编译library_b,需要以以下方式进行编译:

dependencies {
    ...
    compile 'package:library_b:1.0@aar'
    ...
}

I have to add the @aar otherwise gradle won't recognize it, but I didn't have to do that with library_a. 我必须添加@aar,否则gradle无法识别它,但是我不必使用library_a来完成。

The second issue is that when I build the app I get warnings that it can't find references to classes available in library_a. 第二个问题是,在构建应用程序时,我收到警告,提示它找不到对library_a中可用类的引用。 What am I missing over here? 我在这里想念什么? I did try to add transitive=true to library_a 我确实尝试将transitiveive = true添加到library_a

dependencies {
        ...
        compile ('package:library_a:1.0') {
            transitive = true;
        }
        ...
}

but absolutely nothing works. 但绝对没有用。 I did check the pom file and it includes the proper dependencies. 我确实检查了pom文件,它包含适当的依赖项。 Could it be that what I'm doing is not supported by gradle and I have to compile both library_a and library_b in my app? 难道gradle不支持我在做什么,我必须在我的应用程序中同时编译library_a和library_b吗?

Sounds like your maven repo only contains the aar files but no or wrong pom files. 听起来您的Maven存储库仅包含aar文件,但不包含错误的pom文件。

Are you using the following gradle plugin and the uploadArchives gradle task in order to upload the aar s to your maven repository? 您是否正在使用以下gradle插件和uploadArchives gradle任务,以便将aar上载到您的maven存储库? https://github.com/dcendents/android-maven-gradle-plugin https://github.com/dcendents/android-maven-gradle-plugin

try this gradle snippet for your aar s: 尝试为您的aar此gradle片段:

buildscript {
    repositories {
        mavenCentral()
    }

    dependencies {
        classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
    }
}

apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven'

android { ... }

dependencies { ... }

uploadArchives {
    repositories {
        mavenDeployer {
            repository(url: "https://api.bitbucket.org/1.0/repositories/COMPANY/maven_repository/raw/releases") {
                authentication(userName: USERNAME, password: PASSWORD)
            }
        }
    }
}

Then use the uploadArchives gradle task 然后使用uploadArchives gradle任务

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM