其他分享
首页 > 其他分享> > android-如何在Maven中正确设置actionbarsherlock依赖关系?

android-如何在Maven中正确设置actionbarsherlock依赖关系?

作者:互联网

我是新的Maven用户.我想构建由roboguice和actionbarsherlock依赖关系组成的android应用程序.我的问题是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依赖项的Package Explorer中,没有任何actionbarsherlock jar,但是丢失的文件位于target / unpack / apklibs / com.actionbarsherlock_actionbarsherlock_apklib_4.2.0 / src / com / actionbarsherlock / view中

如何正确设置actionbarsherlock依赖性

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

我的项目有2个模块:应用程序和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>

解决方法:

我被这几次抓住了,您实际上必须将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>

标签:maven,dependencies,actionbarsherlock,android
来源: https://codeday.me/bug/20191031/1977006.html