Consuming aar

24 views
Skip to first unread message

Philippe Riand

unread,
Apr 3, 2017, 12:08:45 PM4/3/17
to Maven Android Developers
I'd like to consume the IBM Android mobile first API available here: https://console.ng.bluemix.net/docs/services/mobilepush/c_android_enable.html#tag_based_notifications
I then added the following dependency to my project:
 <dependency>
 
<groupId>com.ibm.mobilefirstplatform.clientsdk.android</groupId>
 
<artifactId>push</artifactId>
 
<version>3.4.1</version>
 
</dependency>

But it fails to find it. After looking at the artifact in my local .m2, I found that the lib is a aar. Fine, I Added the type like this:
 <dependency>
 
<groupId>com.ibm.mobilefirstplatform.clientsdk.android</groupId>
 
<artifactId>push</artifactId>
 
<type>aar</type>
 
<version>3.4.1</version>
 
</dependency>

But then I'm getting another error:The following artifacts could not be resolved: com.android.support:appcompat-v7:jar:23.1.1, com.google.firebase:firebase-messaging:jar:9.0.1
It appears that the module dependencies as defined in the pom are missing the aar type, while these libraries are actually aar:
    <dependency>
     
<groupId>com.android.support</groupId>
     
<artifactId>appcompat-v7</artifactId>
     
<version>23.1.1</version>
     
<scope>compile</scope>
   
</dependency>

As a test, I manually modified the pom of the ibm dependency in my .m2 (just added <type>aar</type>) and it started to work.

Is there an option to force a dependency to be a aar by default for some libraries added? I unsuccessfully tried to set the type in a <dependencyManagement> entry, which seems normal, as the dependency reference contains the type {groupId, artifactId, type, classifier}.
I don't know gradle, but it looks like it does not systematically default to a jar type, but it uses the packaging type of the dependency which makes a lot of sense.

I'm stuck there. I believe that this use case is going to be common when consuming third party lib. Any solution/workaround?

Manfred Moser

unread,
Apr 4, 2017, 3:36:53 PM4/4/17
to maven-androi...@googlegroups.com
Add an exclusion of the wrong dependency to the ibm dependency and then add the right one in as a separate dependency.

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 <mailto:maven-android-deve...@googlegroups.com> .
> For more options, visit https://groups.google.com/d/optout <https://groups.google.com/d/optout> .

Malachi de Ælfweald

unread,
Apr 4, 2017, 3:49:57 PM4/4/17
to maven-androi...@googlegroups.com
I know I haven't been following lately, but...

Looking in my local $ANDROID_HOME/extras/android/m2repository/com/android/support/appcompat-v7/23.1.1/appcompat-v7-23.1.1.pom it does specify <packaging>aar</packaging> and there is no .jar version for it to get confused with... I wouldn't think you would have to manually specify the type when the only one available is specified in it's own pom...?
> To unsubscribe from this group and stop receiving emails from it, send an email to maven-android-developers+unsub...@googlegroups.com <mailto:maven-android-developers+unsubscribe@googlegroups.com> .
--
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-developers+unsub...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

ph...@darwino.com

unread,
Apr 6, 2017, 1:11:55 PM4/6/17
to Maven Android Developers
Thanks, this seems a good workaround. I'll try that.
That said, it should be great if Maven behaves similarly to Gradle as this use case should be common. Moreover, this is not robust over time in particular if IBM changes its own POM.
> To unsubscribe from this group and stop receiving emails from it, send an email to maven-android-developers+unsub...@googlegroups.com <mailto:maven-android-developers+unsubscribe@googlegroups.com> .

ph...@darwino.com

unread,
Apr 6, 2017, 1:11:55 PM4/6/17
to Maven Android Developers
Yes but when you are referencing the dependency, you have to specify aar. The default value is currently always jar, while picking up the packaging type from the pom would be better in my opinion.

Manfred Moser

unread,
Apr 6, 2017, 1:16:50 PM4/6/17
to maven-androi...@googlegroups.com
That would not work easily since packaging is not the same as type e.g.

packaging defined in the pom could be "provisio" for a jar, or "hpi" and there is a hpi as well as a jar file and so on. The only reference between packaging and type is the plugin that implements that .. and that is not known to Maven at runtime when downloading dependencies..

Manfred

ph...@darwino.com wrote on 06.04.2017 05:57:

> Yes but when you are referencing the dependency, you have to specify aar. The default value is currently always jar, while picking up the packaging type from the pom would be better in my opinion.
>
> On Tuesday, April 4, 2017 at 3:49:57 PM UTC-4, Malachi de Ćlfweald wrote:
>>
>>
>> I know I haven't been following lately, but...
>>
>>
>> Looking in my local $ANDROID_HOME/extras/android/m2repository/com/android/support/appcompat-v7/23.1.1/appcompat-v7-23.1.1.pom it does specify <packaging>aar</packaging> and there is no .jar version for it to get confused with... I wouldn't think you would have to manually specify the type when the only one available is specified in it's own pom...?
>>
>>
>> Malachi de Ćlfweald
>> http://www.google.com/ <http://www.google.com/profiles/malachid> profiles/malachid
>>
>>
>> On Tue, Apr 4, 2017 at 12:36 PM, Manfred Moser <man...@mosabuam.com <%20target=> > wrote:
>>> Add an exclusion of the wrong dependency to the ibm dependency and then add the right one in as a separate dependency.
>>>
>>> Manfred
>>>
>>>
>>> Philippe Riand wrote on 02.04.2017 07:08:
>>>
>>> > I'd like to consume the IBM Android mobile first API available here: https://console.ng.bluemix. <https://console.ng.bluemix.net/docs/services/mobilepush/c_android_enable.html#tag_based_notifications> net/docs/services/mobilepush/c_android_enable.html#tag_based_notifications
>>> > To unsubscribe from this group and stop receiving emails from it, send an email to maven-android-developers+ <%20target=> unsub...@googlegroups.com <mailto:maven-android- <%20target=> developers+...@googlegroups.com> .
>>> > For more options, visit https://groups.google.com/d/ <https://groups.google.com/d/optout> optout <https://groups.google.com/d/ <https://groups.google.com/d/optout> optout> .
>>>
>>>
>>> --
>>> 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-developers+ <%20target=> unsub...@googlegroups.com.
>>> For more options, visit https://groups.google.com/d/ <https://groups.google.com/d/optout> optout.
>>>
>>>
> --
> 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 <mailto:maven-android-deve...@googlegroups.com> .

Manfred Moser

unread,
Apr 6, 2017, 1:19:08 PM4/6/17
to maven-androi...@googlegroups.com
Well... whatever Gradle does probably breaks the Maven repository format usage so is not really playing nice with the overall ecosystem as usual.

And it will be robust over time if you do a dependency analysis when you upgrade any dependencies.. something you should be doing anyway. And of course IBM should be educated about their mistake. Is there a place to file a bug?

Manfred

ph...@darwino.com wrote on 06.04.2017 05:55:

> Thanks, this seems a good workaround. I'll try that.
> That said, it should be great if Maven behaves similarly to Gradle as this use case should be common. Moreover, this is not robust over time in particular if IBM changes its own POM.
>
> On Tuesday, April 4, 2017 at 3:36:53 PM UTC-4, Manfred Moser (simpligility) wrote:
>> Add an exclusion of the wrong dependency to the ibm dependency and then add the right one in as a separate dependency.
>>
>> Manfred
>>
>> Philippe Riand wrote on 02.04.2017 07:08:
>>
>> > I'd like to consume the IBM Android mobile first API available here: https://console.ng.bluemix. <https://console.ng.bluemix.net/docs/services/mobilepush/c_android_enable.html#tag_based_notifications> net/docs/services/mobilepush/c_android_enable.html#tag_based_notifications
>> > To unsubscribe from this group and stop receiving emails from it, send an email to maven-android-developers+ <%20target=> unsub...@googlegroups.com <mailto:maven-android- <%20target=> developers+...@googlegroups.com> .
>> > For more options, visit https://groups.google.com/d/ <https://groups.google.com/d/optout> optout <https://groups.google.com/d/ <https://groups.google.com/d/optout> optout> .
>
>
> --
> 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 <mailto:maven-android-deve...@googlegroups.com> .

Malachi de Ælfweald

unread,
Apr 6, 2017, 1:42:43 PM4/6/17
to maven-androi...@googlegroups.com
I believe Gradle will grab the single aar/jar that is there without specifying it.  If both exists, it will only grab the jar without specifying the type.
>> > To unsubscribe from this group and stop receiving emails from it, send an email to maven-android-developers+ <%20target=> unsub...@googlegroups.com <mailto:maven-android- <%20target=> developers+unsubscribe@googlegroups.com> .
>
>
> --
> 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-developers+unsub...@googlegroups.com <mailto:maven-android-developers+unsubscribe@googlegroups.com> .
--
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-developers+unsub...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

ph...@darwino.com

unread,
Apr 9, 2017, 5:30:51 PM4/9/17
to Maven Android Developers
> To unsubscribe from this group and stop receiving emails from it, send an email to maven-android-developers+unsub...@googlegroups.com <mailto:maven-android-developers+unsubscribe@googlegroups.com> .
Reply all
Reply to author
Forward
0 new messages