6

I have worked on an Android library (an API client) that uses Retrofit and Joda DateTime.

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:22.2.0'
    compile 'com.squareup.retrofit:retrofit:1.9.0'
    compile 'joda-time:joda-time:2.8.1'
}

Now that the library is completed I compiled it into an AAR file and I want to use it in an application, so I added it to the libs folder of the application and included it in the build.gradle file like so :

dependencies {
    compile(name:'s3papiandroidclient', ext:'aar')
    //Some other things
}

However, when I try to initialize the API client from the library, the application crashes when it comes to calling objects from RetroFit or DateTime (For instance, retrofit.RestAdapter). It looks like Gradle does not read the dependencies from the AAR library, thus doesn't install Retrofit and DateTime in my application. I tried to use the transitive=true parameter on my AAR file, does not help.

Other point that might help, I tried to generate a POM file, and the dependencies don't appear in it either. It looks like there's really something going on with these and I am completely stuck on that.

The only workaround I could find is to add manually the dependencies from the AAR file to the app's build.gradle file but it doesn't make sense, I assume Gradle can import dependencies on its own !

Regards,

Gyoo.

1 Answer 1

5

It looks like Gradle does not read the dependencies from the AAR library

That is because there are no dependencies in an AAR file.

I tried to generate a POM file, and the dependencies don't appear in it either

Then there is a problem in how you are generating the POM file. Plus, AFAIK, you would need to put the AAR and its POM file in a repository, in order for Gradle to recognize the POM and use the dependency information inside of it.

1
  • 1
    @Gyoo: FWIW, here is one of my libraries that has a dependency upon another one of my libraries. I use the maven plugin and its uploadArchives task for generating the POM and copying it plus the AAR into a local repository (which I then sync to my own public artifact repository upon Amazon S3). Jul 31, 2015 at 12:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.