2

我正在尝试使用 maven 构建一个 android 应用程序,并且我想使用 Spring Android Framework。我已将必要的依赖项添加到我的 pom.xml 中:

<dependencies>
<dependency>
    <groupId>org.springframework.android</groupId>
    <artifactId>spring-android-rest-template</artifactId>
    <version>1.0.1.RELEASE</version>
</dependency>
<dependency>
    <groupId>org.springframework.android</groupId>
    <artifactId>spring-android-auth</artifactId>
    <version>1.0.1.RELEASE</version>
</dependency>
<dependency>
    <groupId>org.springframework.android</groupId>
    <artifactId>spring-android-core</artifactId>
    <version>1.0.1.RELEASE</version>
</dependency>

使用 maven-eclipse-plugin 2.9 构建使用 maven 失败。我还尝试使用命令行 maven 3.0.5 构建我的项目,两种方法都告诉我:

[INFO] UNEXPECTED TOP-LEVEL EXCEPTION:
[INFO] java.lang.IllegalArgumentException: already added: Lorg/springframework/core/ErrorCoded;

如果我从 pom.xml 中删除 spring-andoid-auth 依赖项,则项目将成功构建。但是,如果我只将它作为依赖项,并删除其他所有内容,则错误保持不变。

所以我想构建 spring-android-auth 工件存在问题。我做错了什么,还是有人遇到同样的问题?如果可以修复,我应该如何修复它?

这是该项目的实际整个 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>
    <groupId>com.super.secret.project</groupId>
    <artifactId>super-secret-project</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>apk</packaging>
    <name>SuperSecretProject</name>


    <properties>
        <spring-android-version>1.0.1.RELEASE</spring-android-version>
        <android-version>4.1.1.4</android-version>
        <slidingmenu-version>1.3-SNAPSHOT</slidingmenu-version>
        <lombok-version>1.12.2</lombok-version>
        <android-annotations-version>2.2</android-annotations-version>
        <maven-eclipse-plugin-version>2.9</maven-eclipse-plugin-version>
        <android-platform>17</android-platform>
    </properties>

    <dependencies>

        <dependency>
            <groupId>org.springframework.android</groupId>
            <artifactId>spring-android-rest-template</artifactId>
            <version>${spring-android-version}</version>
        </dependency>

        <dependency>
            <groupId>org.springframework.android</groupId>
            <artifactId>spring-android-core</artifactId>
            <version>${spring-android-version}</version>
        </dependency>


        <dependency>
            <groupId>org.springframework.android</groupId>
            <artifactId>spring-android-auth</artifactId>
            <version>${spring-android-version}</version>
        </dependency>


        <dependency>
            <groupId>com.google.android</groupId>
            <artifactId>android</artifactId>
            <version>${android-version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.jeremyfeinstein.slidingmenu</groupId>
            <artifactId>slidingmenu</artifactId>
            <version>${slidingmenu-version}</version>
            <type>jar</type>
        </dependency>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <version>${lombok-version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.googlecode.androidannotations</groupId>
            <artifactId>androidannotations</artifactId>
            <version>${android-annotations-version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.googlecode.androidannotations</groupId>
            <artifactId>androidannotations</artifactId>
            <classifier>api</classifier>
            <version>${android-annotations-version}</version>
        </dependency>

    </dependencies>

    <build>
        <finalName>${project.artifactId}</finalName>
        <sourceDirectory>src</sourceDirectory>

        <plugins>
            <plugin>
                <groupId>com.jayway.maven.plugins.android.generation2</groupId>
                <artifactId>android-maven-plugin</artifactId>
                <version>3.7.0</version>
                <extensions>true</extensions>
                <configuration>
                    <sdk>
                        <platform>${android-platform}</platform>
                    </sdk>
                </configuration>
            </plugin>

            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-eclipse-plugin</artifactId>
                <version>${maven-eclipse-plugin-version}</version>
                <configuration>
                    <downloadSources>false</downloadSources>
                    <downloadJavadocs>false</downloadJavadocs>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

先感谢您!

4

1 回答 1

5

我猜你的 :spring-android-auth 依赖有问题,这个依赖与 :spring-android-core library 冲突。

我建议您从中排除 org.springframework.spring-core :

<dependency>
  <groupId>org.springframework.android</groupId>
  <artifactId>spring-android-auth</artifactId>
  <version>${spring-android-version}</version>
  <exclusions>

    <!-- Exclude in favor of Spring Android Core -->
    <exclusion>
      <artifactId>spring-core</artifactId>
      <groupId>org.springframework</groupId>
    </exclusion>

  </exclusions>
</dependency>
于 2013-10-18T15:55:35.833 回答