Struggling with getting any AAR imported in IntelliJ Ultimate 14.1.2. Don't understand maven-android-sdk-deployer

914 views
Skip to first unread message

Frode Nilsen

unread,
May 4, 2015, 8:51:55 PM5/4/15
to maven-androi...@googlegroups.com
I'm getting really frustrated now - spent way too many hours getting support library v7 imported in a simple maven-enabled Android project i IntellIJ IDEA 14.1.2. Here is a repo

I've tried using maven-android-sdk-deployer to install the AAR's in my maven repo to no avail, and I've tried posting to the official IntelliJ forum without getting much help. I escalated it by posting a bug

So what's the deal? Is it supposed to be this hard? Can anyone please try and clone the example repo ans see if it builds? Is it my maven configurations that there's something wrong with, the IDE or the project?

As for the maven-android-sdk-deployer, I'd really like someone to explain to me why it's needed at all, now that Google is publishing their own M2 repository with the SDK, and IDEA/Android Studio (supposedly) is supporting AAR imports. To me it looks like it merely copies file from one location to another on my hard drive, eliminating the simple task of modifying settings.xml for maven to point to Google's repositories.

Here's a screenshot illustrating my issues:


Andrew Bowley

unread,
May 6, 2015, 6:59:42 AM5/6/15
to maven-androi...@googlegroups.com
Hi Frode

I had a look at your project and it is set up to be built by Ant and has a Maven POM configuration file thrown in with artifact references which are pertfect for Gradle. My humble suggestion is to go with Gradle as Google is promoting it along with Android Studio.

Anyway, I downloaded and installed IntelliJ IDEA Community edition to see if I could help provide you some steps to follow to move forward.

My only exposure to IntelliJ IDEA is by the latest release of Android Studio. The look an feel should be familiar to you.

Here is what I did to set up an Android project for an application using the compatibility v7 library (aar).
It will smooth the process if you install the "Android Support Repository" v14 along with API 21 SDK Platfoorm.

1. Create New Project -> Android -> Gradle: Android Module -> Next
2. In "New Project" Window set Java SDK and Android SDK Location and hit Next
3. In the next window is for the Application configuration. Name "myapp"..
4. Tick "Support Mode - Action Bar" box. This will draw in the compatibility v7 library. Next.
5. For activity I selected "Blank Activity with Fragment" as this is what I know works. Next.
6. For "Activity Name" etc just accept defaults. Next. Finish.
7. Wait an enternity for Gradle to be downloaded and installed.
8. The project will build without errors.

The MainActivity class extends android.support.v7.app.ActionBarActivity, just as in your sample.

The "magic" of binding the v7 Support Library to the application is done by a single line in the Gradle configuration:
compile 'com.android.support:appcompat-v7:21.+'
This causes the library to be included in the build sourced from the Android Support Repository in the SDK.

Your confusion is understandable as, only Gradle can directly access the Android SDK to import libraries. Other build systems must go about this indirectly.
I have no idea how this is meant to be done with IntelliJ IDEA, but there is are Support Library projects for Eclipse in the SDK.
Maven adds more angst because Google refuses to make library modules available from online respositories. 
This is why the maven-android-sdk-deployer came about. It takes modules from the SDK and places them in the local Maven repository.

If you want to use Maven, then you can configure Gradle to access Maven repositories and reference artifacts in the usual way.

One other little thing. I noticed your AndroidManifest.xml set android:minSdkVersion="21". This does not make sense when using a compatibility library!

Hope this helps.

Csaba Kozák

unread,
May 10, 2015, 3:05:07 PM5/10/15
to maven-androi...@googlegroups.com
Unfortunately the maven android SDK deployer is still needed. Google indeed created a local Maven repo in their SDK, but the core android.jar is not distributed within it...
Also, adding that local repo to your project is really inconvenient and not portable. You just use the deployer and all the deps will be available in the standard, local repository which is understandable by all tools. Or even better, deploy the dependencies to your company Nexus, and just reference it and all your build environments will have a central access to the Android dependencies.

Your POM is totally imcomplete, you have to add the Android dependency, the android-maven-plugin and the APK packaging.
Also you should the standard project structure (src/main/res, src/main/AndroidManifest.xml).
Finally, your manifest using  "@android:style/Theme.AppCompat" but it should "@style/Theme.AppCompat".

After correcting these problems, you will be able to build from command line.
Importing to IntelliJ is easy, import and click configure framework when the dialog pops
However you have to manually adjust the project folders, and also create a launch configuration.
Due to some bugs, IntelliJ cannot read them from the POM.

I quickly corrected your example in my fork.


Reply all
Reply to author
Forward
0 new messages