0

To simplify things I'm going to call the libraries I'm using library_a.aar and 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_b depends on library_a and added to library_b as follows:

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.

Now my application depends on library_b which I need to add by providing (as above) the repository along with the credentials.

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:

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.

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. What am I missing over here? I did try to add transitive=true to 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. 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?

Karim Fikani
  • 356
  • 3
  • 23

1 Answers1

0

Sounds like your maven repo only contains the aar files but no or wrong pom files.

Are you using the following gradle plugin and the uploadArchives gradle task in order to upload the aars to your maven repository? https://github.com/dcendents/android-maven-gradle-plugin

try this gradle snippet for your aars:

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

larsgrefer
  • 2,735
  • 19
  • 36
  • the pom file is there with the right dependencies. I have used GitAsMaven github example (https://github.com/JeroenMols/GitAsMaven). – Karim Fikani Nov 21 '16 at 18:31