AAR support

727 views
Skip to first unread message

Manfred Moser (simpligility)

unread,
Oct 2, 2013, 1:48:47 AM10/2/13
to maven-androi...@googlegroups.com
Hi all!

As you all know we have experimental support to create Android Archives (aar) in the 3.7.0 release. Consumption is not yet working.

There are now two sample projects in the maven android plugin samples project

maven-android-plugin-samples/libraryprojects/aar-lib1

is an example for an aar creation and works

maven-android-plugin-samples/libraryprojects/aar-actionbarsherlock-example

is an example for using the ActionBarSherlock aar in your own application. This module is deactivated since it is not yet working. If you want to help.. get this one to work ;-) 

Currently it fails the compilation .. my guess is that the classes file from the aar does not get extracted and put onto the classpath correctly.

Maybe somebody is going to beat me to fixing this one while I look at Maven 3.1.1 and other cleanups.. 

manfred

Benoit Billington

unread,
Oct 2, 2013, 2:53:46 AM10/2/13
to maven-androi...@googlegroups.com

Hi, I would like to continue and finish the implementation but what would be the proper way to add the classes.jar to the classpath?
Normally we have a jar dependency in the pom.

If someone can point me in the right direction that would be great or if someone else does it it's good also.

--
You received this message because you are subscribed to the Google Groups "Maven Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to maven-android-deve...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Martynas Jurkus

unread,
Oct 2, 2013, 5:02:49 AM10/2/13
to maven-androi...@googlegroups.com
It would be awesome if you could update changelog that consumption is not yet working. Spent an hour trying to add play-services.aar to my project :)
And workaround by adding jar dependency does not work as there is no such jar with play-services:3.2.25.

Donn Felker

unread,
Oct 3, 2013, 11:58:13 AM10/3/13
to maven-androi...@googlegroups.com
Glad I found this post, I almost went down the route of getting it to work. :) 

Shu

unread,
Oct 3, 2013, 4:05:52 PM10/3/13
to maven-androi...@googlegroups.com
Would aether be something worth using to finish this task?
To unsubscribe from this group and stop receiving emails from it, send an email to maven-android-developers+unsub...@googlegroups.com.

Manfred Moser

unread,
Oct 3, 2013, 7:15:58 PM10/3/13
to maven-androi...@googlegroups.com
Let me talk to Jason about this. Basically we have to do extract the
classes out of the aar early in the build process and add them into target
and onto the classpath for compilation.

Thats as far as I understand things. Might be worth looking at the source
code of the build helper plugin on how to add stuff to the
classpath/compile path..

manfred
>>> email to maven-android-deve...@googlegroups.com.
>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Maven Android Developers" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to maven-android-deve...@googlegroups.com.

Shu

unread,
Oct 4, 2013, 8:43:46 AM10/4/13
to maven-androi...@googlegroups.com
I tried something but it doesn't work


I tried to hook before the compilation to add the jar to the classpath but it doesn't completely work.
the jar gets added but then during compilation it can't find it.... I'm surely doing something wrong but I don't know what to do right now to fix it.

It would be good if someone could look into it and point me in a direction to fix it :)

Neal Sanche

unread,
Oct 6, 2013, 3:14:54 PM10/6/13
to maven-androi...@googlegroups.com
This is very cool!

So, I tried this out, in order to make .aar files from older apklib maven projects, and was able to get some working well. I've been using Gradle with Android Studio. It doesn't consume apklib, but is supposed to consume .aar files. So, I clone a library project made with Maven, upgrade it to use the Maven Android plugin 3.7.0 and then change it's packaging type from apklib to aar. Then I do a 'maven install'. It builds an apklib and installs it into my local maven repository. So far so good.

In Gradle, I will add these libraries to my build.gradle file. I had success with getting the code to work, however, I'm not so sure the resource files are getting into the .aar, or being consumed by gradle correctly. (I don't know the correct diagnosis here, I am just speculating.) I'd love for this to work properly. Any ideas? I don't see anything fundamentally different in the exploded .aar files so far. This could be a problem on the Gradle side too. Not sure.

Neal

Kevin Kovach

unread,
Oct 7, 2013, 2:47:58 PM10/7/13
to maven-androi...@googlegroups.com
This is great to see. Thanks for all of the hard work.

First question after looking at the examples. I'm either not seeing or not understanding how I can create both an apklib and an aar? Is this possible? Do I need more than one pom for this?  Thanks!

- Kevin

Manfred Moser

unread,
Oct 7, 2013, 2:55:05 PM10/7/13
to maven-androi...@googlegroups.com
It should produce an aar . not an apklib. If there is something missing or
wrong please let us know.

And maybe even provide a fix ;-)

Kevin Kovach

unread,
Oct 7, 2013, 3:05:37 PM10/7/13
to maven-androi...@googlegroups.com, man...@simpligility.com
No, it does produce an aar file. I was not trying to suggest that it didn't.

I was wondering if/how I could produce both?  We have some folks that prefer an apklib and I'm trying to please everyone.  :-)

So, I'm guessing I would need a separate pom then with an apklib packaging type?  I was just trying to make sure I wasn't missing something.  Thanks again.

- Kevin

Manfred Moser

unread,
Oct 7, 2013, 3:08:57 PM10/7/13
to Kevin Kovach, maven-androi...@googlegroups.com, man...@simpligility.com
Yes... you would need another project. At this stage we will pretty much
move over to aar support once that is solid and apklib will go into legacy
support as soon as we have parity in terms of features of aar vs apklib

It might be worth looking into creating an aar project where it just has a
dependency to an apklib and basically transforms the apklib into an aar.

Could you create a sample project like that in the samples project and
send a pull request? That would help with development imho.

manfred
>> maven-android-deve...@googlegroups.com<javascript:>.

Shu

unread,
Oct 9, 2013, 9:38:15 AM10/9/13
to maven-androi...@googlegroups.com
Anyone with a hint to complete the support of consuming aar's ?

Shu

unread,
Oct 16, 2013, 5:10:06 AM10/16/13
to maven-androi...@googlegroups.com
Btw there is also the R.txt file that needs to be consumed by android-maven-plugin otherwise we cannot use resources.

Shu

unread,
Oct 16, 2013, 10:10:55 AM10/16/13
to maven-androi...@googlegroups.com
For the R.txt file it's worth checking https://android.googlesource.com/platform/tools/build/+/master/builder/src/main/java/com/android/builder/AndroidBuilder.java
Line 636 and below.

Btw why is android-maven-plugin not using the AndroidBuilder class ?

Manfred Moser

unread,
Oct 16, 2013, 11:36:31 AM10/16/13
to maven-androi...@googlegroups.com
The AndroidBuilder class did not exist when we wrote all this code. Imho
we should move to using it. AAR support might be a first step to use it.

manfred
> --
> You received this message because you are subscribed to the Google Groups
> "Maven Android Developers" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to maven-android-deve...@googlegroups.com.

Shu

unread,
Oct 16, 2013, 11:46:14 AM10/16/13
to maven-androi...@googlegroups.com, man...@simpligility.com
Ok ;)

So I made a pull request to support something else in the consumption of an aar (still not the classes.jar)


I didn't use the AndroidBuilder but copied stuff from it. (so bad) the reason is that we need to refactor way more in order to use AndroidBuilder as it should not only be used for AAR support.

Cheers

I'm willing to refactor stuff with other people but I'll need time ;) 

Manfred Moser

unread,
Oct 16, 2013, 11:53:11 AM10/16/13
to Shu, maven-androi...@googlegroups.com, man...@simpligility.com
Great. Don't rush things. Ideally we get aar support working and cut a new
release after. If people need it quick.. they should help. I might end up
forking the plugin-testing..

manfred

Shu

unread,
Oct 18, 2013, 8:56:35 AM10/18/13
to maven-androi...@googlegroups.com, Shu, man...@simpligility.com
There is a talk going on in the maven mailing list so if you want to help us on how using the classes.jar it can also be done there:

Shu

unread,
Oct 20, 2013, 11:21:44 AM10/20/13
to maven-androi...@googlegroups.com, Shu, man...@simpligility.com
finally another pull request to support classes.jar.

We can make a new release of the plugin to test with aar.

Note: optional stuff still needs to be implemented:
  • /libs/*.jar (optional)
  • /proguard.txt (optional)
  • /lint.jar (optional, not used yet)

Manfred Moser

unread,
Oct 21, 2013, 2:19:37 PM10/21/13
to Shu, maven-androi...@googlegroups.com, Shu, man...@simpligility.com
> finally another pull request to support classes.jar.
>
> We can make a new release of the plugin to test with aar.
>
> Note: optional stuff still needs to be implemented:
>
> - /libs/*.jar (optional)

I think we should NOT implement this, but rather just throw a big fat
warning that says that libs should be transitive dependencies and NOT
included in the aar.

> - /proguard.txt (optional)

Sure..

> - /lint.jar (optional, not used yet)

Thats mostly a nice to have idea... and will affect only very few libraries.
Reply all
Reply to author
Forward
0 new messages