Java – Maven Android plugin with Android Support Library v7

Maven Android plugin with Android Support Library v7… here is a solution to the problem.

Maven Android plugin with Android Support Library v7

I build my Android application using Maven-Android-Plugin, which relies on the Android support libraries v4 and v7.
Because I didn’t find out how to download the entire SDK from developer.android.com, I didn’t use the Maven Android Deployee tool to set up a local repository for the Android SDK. So I want to use the support library included in adt-bundle, here’s how I wrote the dependencies in pom.xml:

        <dependency>
        <groupId>android.support</groupId>
        <artifactId>compatibility-v7</artifactId>
        <version>18</version>
        <scope>system</scope>
        <systemPath>${project.basedir}/appcompat/libs/android-support-v7-appcompat.jar</systemPath>
    </dependency>
    <dependency>
        <groupId>android.support</groupId>
        <artifactId>compatibility-v4</artifactId>
        <version>18</version>
        <scope>system</scope>
        <systemPath>${project.basedir}/appcompat/libs/android-support-v4.jar</systemPath>
    </dependency>
    <dependency>
        <groupId>android.support</groupId>
        <artifactId>compatibility</artifactId>
        <version>18</version>
        <scope>system</scope>
        <systemPath>${project.basedir}/appcompat.apklib</systemPath>
        <type>apklib</type>
    </dependency>
    <dependency>
        <groupId>android.support</groupId>
        <artifactId>compatibility</artifactId>
        <version>18</version>
        <scope>system</scope>
        <systemPath>${project.basedir}/appcompat/bin/appcompat.jar</systemPath>
    </dependency>

The first two were written by me at the beginning, but Maven reported a mistake:

No resource found that matches the given name 'Theme.AppCompat.Light'.

Then I added a third one. I zipped the v7 project and renamed it to .apklib. But it still doesn’t work.
Finally I added the last one, but it doesn’t work either. So how do you write the right pom to solve this problem?
My System Information:

Apache Maven 3.0.4
Java version: 1.7.0_25, vendor: Oracle Corporation
Android Platform Version:4.3
Android Maven Plugin:3.6.0

Solution

When I played with this, I added a <type>jar</type> and a <type>

apklib</type>.

  • I did this: https://stackoverflow.com/a/18796764/1738827
  • My pom file looks like this:

    <dependency>
        <groupId>com.android.support</groupId>
        <artifactId>appcompat-v7</artifactId>
        <version>18.0.0</version>
        <type>apklib</type>
        <scope>compile</scope>
    </dependency>
    <dependency>
        <groupId>com.android.support</groupId>
        <artifactId>appcompat-v7</artifactId>
        <version>18.0.0</version>
        <type>jar</type>
        <scope>compile</scope>
    </dependency>
    

Related Problems and Solutions