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.

mariodev
  • 13,928
  • 3
  • 49
  • 61
nano
  • 2,511
  • 4
  • 25
  • 42
  • Instead of creating a new dependency, you can [Include official android support in maven][1] [1]: http://stackoverflow.com/a/29153638/1345391 – JavierSP1209 Mar 19 '15 at 19:58

3 Answers3

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>
dangVarmit
  • 5,641
  • 2
  • 22
  • 24
  • 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 '13 at 16:01
1

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

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

kassim
  • 3,880
  • 3
  • 26
  • 27
  • Yeah, thanks, but I'd want to learn to generate it by my own. – nano Aug 24 '13 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 '13 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 '13 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

  • 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. – George Baker Jun 12 '14 at 15:37