如何在maven中正确设置actionbarsherlock依赖项?

时间:2012-11-23 11:54:45

标签: android maven dependencies actionbarsherlock

我是新的maven用户。我想构建我的android应用程序,它包含roboguice和actionbarsherlock依赖。我的问题是actionbarsherlock依赖。我把它包括在内

    <dependency>
        <groupId>com.actionbarsherlock</groupId>
        <artifactId>actionbarsherlock</artifactId>
        <version>4.2.0</version>
        <type>apklib</type>
    </dependency>

    <!-- Let Roboguice and Sherlock work together -->
    <dependency>
        <groupId>com.github.rtyley</groupId>
        <artifactId>roboguice-sherlock</artifactId>
        <version>1.4</version>
    </dependency>

在模块pom.xml文件中,但我的编辑器无法导入actionbarsherlock视图类。在maven依赖的包资源管理器中,没有任何actionbarsherlock jar,但是miss目录/ unpack / apklibs / com.actionbarsherlock_actionbarsherlock_apklib_4.2.0 / src / com / actionbarsherlock / view

如何正确设置actionbarsherlock依赖???

我的开发IDE是eclipse。我已经在eclipse中为m2e安装了m2e,android配置,并且可以导入android maven项目。

我的项目有2个模块:application和facebook sdk。我将Android版本设置为15.

在pom.xml文件中:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>application</artifactId>
<name>Grand</name>
<packaging>apk</packaging>

<parent>
    <groupId>pl.grand</groupId>
    <artifactId>Grand</artifactId>
    <version>1.0.0</version>
    <relativePath>../pom.xml</relativePath>
</parent>

<dependencies>
    <dependency>
        <groupId>com.google.android</groupId>
        <artifactId>android</artifactId>
        <scope>provided</scope>
    </dependency>

    <dependency>
        <groupId>org.roboguice</groupId>
        <artifactId>roboguice</artifactId>
        <version>2.0</version>
    </dependency>

    <dependency>
        <groupId>com.actionbarsherlock</groupId>
        <artifactId>actionbarsherlock</artifactId>
        <version>4.2.0</version>
        <type>apklib</type>
    </dependency>

    <!-- Let Roboguice and Sherlock work together -->
    <dependency>
        <groupId>com.github.rtyley</groupId>
        <artifactId>roboguice-sherlock</artifactId>
        <version>1.4</version>
    </dependency>

    <!-- facebook sdk -->
    <dependency>
        <groupId>com.facebook.android</groupId>
        <artifactId>facebook-android-sdk</artifactId>
        <version>1.0.1</version>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>com.jayway.maven.plugins.android.generation2</groupId>
            <artifactId>android-maven-plugin</artifactId>
            <extensions>true</extensions>
            <configuration>
                <sdk>
                    <platform>15</platform>
                </sdk>
            </configuration>
        </plugin>

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.3.2</version>
            <configuration>
                <source>1.6</source>
                <target>1.6</target>
            </configuration>
        </plugin> 
    </plugins>
</build>

1 个答案:

答案 0 :(得分:4)

我已经被这几次抓住了,你实际上要将APKLIB和JAR依赖项添加到你的项目中(其中APKLIb带来了资源以及所有这些都是Android Library项目的一部分)并且JAR带来了编译类。

实际上:

<dependency>
    <groupId>com.actionbarsherlock</groupId>
    <artifactId>actionbarsherlock</artifactId>
    <version>4.2.0</version>
    <type>apklib</type>
</dependency>

<dependency>
    <groupId>com.actionbarsherlock</groupId>
    <artifactId>actionbarsherlock</artifactId>
    <version>4.2.0</version>
    <type>jar</type>
</dependency>