Android project using Maven with AAR for not having Eclipse errors

By : nano
Source: Stackoverflow.com
Question!

I have an android project that uses several libraries:

  • play-services for analytics,
  • appcompat-v7 for the actionar,
  • and others... (for ads, in-app...)

I used to use APKLIB packaging and I was able to generate the APK of my project, but having hundreds of errors in Eclipse. So my intention is to fix this for not having any error at all }:-)

I discovered the AAR format and all this gradle staff, but I'd like to keep using my maven structure as it is.

So I got the AAR package of play_services (thanks to https://github.com/mosabua/maven-android-sdk-deployer) and generated the AAR package of appcompat-v7 and the others libs.

And I almost made this happen, excepting some errors with styles and other missing resources from those libs that are still not found:

Error: No resource found that matches the given name (at 'value' with value '@integer/google_play_services_version').   
Error: No resource found that matches the given name (at 'theme' with value '@style/Theme.AppCompat.Light').    

This is an example of some of my dependencies:

    <dependency>
      <groupId>com.google.android.gms</groupId>
      <artifactId>play-services</artifactId>
      <version>5.0.77</version>
      <type>aar</type>
    </dependency>
    <dependency>
        <groupId>com.google.android</groupId>
        <artifactId>android</artifactId>
        <version>4.1.1.4</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>android.support</groupId>
        <artifactId>compatibility-v7-appcompat</artifactId>
        <version>20.0.0</version>
        <type>jar</type>
    </dependency>
    <dependency>
        <groupId>android.support</groupId>
        <artifactId>compatibility-v7-appcompat</artifactId>
        <version>20.0.0</version>
        <type>aar</type>
    </dependency>
    <dependency>
        <groupId>android.support</groupId>
        <artifactId>compatibility-v4</artifactId>
        <version>20.0.0</version>
    </dependency>

My questions are:

  • Does it worth to forget Maven and move to Gradle for using Android apps? (Please say no :)
  • Is it not possible to get the dependencies resources using AAR packaging? I don't want to import all my projects in Eclipse for having access to their resources.
By : nano


Answers

Move to Gradle, it might pay off the effort you have to do to fix it. These new google libraries are more and more made for Gradle. Android-Maven-Plugin isn't mature enough to work well with AAR files the way APKLIB used to work, so it might require a lot of little adaptations. So if that is the case, I would recommend to spend this precious time with Gradle instead.

Note: by "moving to Gradle" it doesn't necessarily mean that you have to switch to Android Studio. You can still use this great IDE that Eclipse is ;-)



This video can help you solving your question :)
By: admin