Generate APKLIB of compatibility-v7-appcompat

2019-02-13 22:29发布

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.

3条回答
唯我独甜
2楼-- · 2019-02-13 23:02
    <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

查看更多
疯言疯语
3楼-- · 2019-02-13 23:07

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

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

查看更多
Anthone
4楼-- · 2019-02-13 23:20

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>
查看更多
登录 后发表回答