6

I have a library in the Maven Central Repository. For the latest release I have pushed an .aar archive in addition to the normal .jar.

However I can't seem to get Android Studio to use the aar version of the library. In my build.gradle file I have:

dependencies {
    compile 'com.android.support:appcompat-v7:19.+'
    compile 'com.mygroup:mylibrary:1.2.2'
}

This successfully fetched the jar file, but how do I get it to use the aar version of the library? I tried a number of things, including (but not limited to):

compile 'com.mygroup:mylibrary:1.2.2@aar'
compile group: 'com.mygroup', name: 'mylibrary', version: '1.2.2', type: 'aar'
compile group: 'com.mygroup', name: 'mylibrary', version: '1.2.2', packaging: 'aar'
compile group: 'com.mygroup', name: 'mylibrary', version: '1.2.2', extension: 'aar'

But it always loads the jar.

Is Gradle expecting the artifact to contain just the AAR only (with a POM that matches)? Do I need to create a separate artifact for the AAR version of the lib?

Paul LeBeau
  • 97,474
  • 9
  • 154
  • 181
  • [This](http://stackoverflow.com/questions/20551160/gradle-for-android-aar-depending-upon-aar-both-in-the-same-remote-repository?rq=1) might help – Infinite Recursion Jun 17 '14 at 04:56
  • Thanks for the link. That doesn't seem to offer any clues as to the answer to my particular problem though. – Paul LeBeau Jun 17 '14 at 07:00
  • 1
    As for me `compile 'net.danlew:android.joda:2.3.4@aar'` works. Can you compare this library and yours in maven central. Check pom and artifacts – Eugen Martynov Jun 17 '14 at 21:46
  • What version of android gradle plugin do you use? – Eugen Martynov Jun 17 '14 at 21:46
  • I'm using the latest Gradle plugin. I see that your artifact has only the aar. And your pom references the aar. So maybe I *do* just have to have a separate artifact or version for the aar. – Paul LeBeau Jun 18 '14 at 01:17
  • @PaulLeBeau Can you post the code you use to upload? Javadocs, AAR, JARs, etc are separate artifacts that can be uploaded under the same group/artifactId/version. – Jared Burrows Apr 10 '16 at 20:27
  • Why would the method of upload make a difference? I haven't tested this for a long time. I don't know whether this problem still exists. – Paul LeBeau Apr 10 '16 at 21:35

0 Answers0