5

I want to start using the new ActionBar of the appcompat-v7 support library, and I'm using maven. I tried to create an apklib. These are the steps I followed:

  1. Create a ZIP file of the project android-sdks/extras/android/support/v7/appcompat
  2. Rename the ZIP file with an APKLIB extension.
  3. Install the APKLIB file into my local repository:

C:....m2\repository\android\support\compatibility-v7-appcompat\18>mvn install:install-file -Dfile=appcombat.apklib -DgroupId=android.support -DartifactId=appcompat -Dversion=18 -Dpackaging=apklib

Start using the library from my android project adding this dependency in the pom:

    <dependency>
        <groupId>android.support</groupId>
        <artifactId>appcompat</artifactId>
        <version>18</version>
        <type>apklib</type>
    </dependency>

But it's not working. I'm getting an error of missing artifact.
Any help would be much appreciated.

1

3 Answers 3

8

The is a way to install appcompat into your local repository without relying on Maven SDK deployer...

From the Android SDK Manager, install the 'Android Support Repository' option. go into your SDK folder, then into ./extras/m2Repository/com/android/support/appcompat-v7/18.0.0

open the appcompat-v7-18.0.0.aar file and copy the classes.jar out to a file named appcompat-v7-18.0.0.jar

at the command line go into the same m2Repository folder and run the following commands:

mvn install:install-file -Dfile="./com/android/support/appcompat-v7/18.0.0/appcompat-v7-18.0.0.jar"/ -DpomFile="./com/android/support/appcompat-v7/18.0.0/appcompat-v7-18.0.0.pom"/ -Dpackaging="jar"
mvn install:install-file -Dfile="./com/android/support/appcompat-v7/18.0.0/appcompat-v7-18.0.0.aar"/ -DpomFile="./com/android/support/appcompat-v7/18.0.0/appcompat-v7-18.0.0.pom"/ -Dpackaging="apklib"

Then add the following two dependencies in your project's POM

    <dependency>
        <groupId>com.android.support</groupId>
        <artifactId>appcompat-v7</artifactId>
        <version>18.0.0</version>
        <type>apklib</type>
    </dependency>
    <dependency>
        <groupId>com.android.support</groupId>
        <artifactId>appcompat-v7</artifactId>
        <version>18.0.0</version>
        <type>jar</type>
    </dependency>
1
  • 1
    appcompat-v7 also depends on support-v4, so you'll also need to run the following command from the same m2repository folder: mvn install:install-file -Dfile="./com/android/support/support-v4/18.0.0/support-v4-18.0.0.jar"/ -DpomFile="./com/android/support/support-v4/18.0.0/support-v4-18.0.0.pom"/ -Dpackaging="jar"
    – LightStruk
    Oct 18, 2013 at 16:01
1

The apklib generated with maven-android-sdk-deployer works fine for me.

https://github.com/mosabua/maven-android-sdk-deployer

3
  • Yeah, thanks, but I'd want to learn to generate it by my own.
    – nano
    Aug 24, 2013 at 15:36
  • 1
    I'm not sure how to install the compatibility-v7-appcompat v19 using maven-android-sdk-deployer. I run mvn install -P 4.4 but the compatibility-v7-appcompat v19 is not installed in my local maven repository. What command should I run?
    – Giorgio
    Nov 21, 2013 at 13:03
  • 1
    just navigate to the directory (maven-android-sdk-deployer/extras/compatibility-v7-appcompat) and run mvn clean install (though I'm not sure if the clean is necessary)
    – kassim
    Nov 21, 2013 at 14:59
0
    <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>
    </dependency>
    <dependency>
        <groupId>com.android.support</groupId>
        <artifactId>support-v4</artifactId>
        <version>18.0.0</version>
    </dependency>

I have put these dependencies on pom file but it says to put android:theme="@style/Theme.AppCompat.Light" at manifest while clean and build and I put it on manifest but still I got same error.But when i change

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

to

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

it compiles and run on android but android manifest still shows red line on android:theme="@style/Theme.AppCompat.Light" in eclipse.So I don't know what to do to remove this red line error on eclipse on manifest file

1
  • If you haven't solved this problem yet you also need to have the library in eclipse. Android-Maven-plugin only handles dependencies while building. Eclipse is generating the warning and it can't process the dependencies. Jun 12, 2014 at 15:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.