maven android插件与android支持库v7

时间:2013-10-19 06:45:02

标签: java android maven

我使用maven-android-plugin来构建我的Android应用程序,这取决于android支持库v4和v7。 由于我没有找到如何从developer.android.com下载整个sdk,我没有使用maven android deployee工具来设置android sdk的本地存储库。因此我想使用adt-bundle中包含的支持库,下面是我在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>

前两个是我在开始时写的,但是maven提出了一个错误:

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

然后我添加了第三个。我压缩v7项目并重命名为.apklib。但它仍然不起作用 最后我添加了最后一个,但它也不起作用。那么如何编写正确的pom来解决这个问题呢? 我的系统信息:

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

2 个答案:

答案 0 :(得分:0)

当我玩这个时,我添加了<type>jar</type><type>apklib</type>。我不记得所有的细节。

  • 我这样做了:https://stackoverflow.com/a/18796764/1738827
  • 我的pom文件有这个:

    <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>
    

答案 1 :(得分:0)

试试这个:

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

我用过这个,Theme.Appcompat.Light可见。