Android Maven 安装上的 IllegalArgumentException

IllegalArgumentException on Android Maven Install

我在 Android 项目上尝试 "mvn install" 时遇到以下异常。

[INFO] UNEXPECTED TOP-LEVEL EXCEPTION:
[INFO] java.lang.IllegalArgumentException: already added: Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoIcsImpl;
[INFO]  at com.android.dx.dex.file.ClassDefsSection.add(ClassDefsSection.java:122)
[INFO]  at com.android.dx.dex.file.DexFile.add(DexFile.java:161)
[INFO]  at com.android.dx.command.dexer.Main.processClass(Main.java:685)
[INFO]  at com.android.dx.command.dexer.Main.processFileBytes(Main.java:634)
[INFO]  at com.android.dx.command.dexer.Main.access0(Main.java:78)
[INFO]  at com.android.dx.command.dexer.Main.processFileBytes(Main.java:572)
[INFO]  at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:284)
[INFO]  at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:166)
[INFO]  at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)
[INFO]  at com.android.dx.command.dexer.Main.processOne(Main.java:596)
[INFO]  at com.android.dx.command.dexer.Main.processAllFiles(Main.java:498)
[INFO]  at com.android.dx.command.dexer.Main.runMonoDex(Main.java:264)
[INFO]  at com.android.dx.command.dexer.Main.run(Main.java:230)
[INFO]  at com.android.dx.command.dexer.Main.main(Main.java:199)
[INFO]  at com.android.dx.command.Main.main(Main.java:103)

看起来好像存在某种依赖冲突。我的pom如下

<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/xsd/maven-4.0.0.xsd">
    <parent>
        <groupId>com.x.y.z</groupId>
        <artifactId>parent</artifactId>
        <version>0.0.1-SNAPSHOT</version>
        <relativePath>../../parent</relativePath>
    </parent>

    <modelVersion>4.0.0</modelVersion>
    <artifactId>android-project</artifactId>
    <packaging>apk</packaging>

    <build>
        <plugins>
            <plugin>
                <groupId>com.jayway.maven.plugins.android.generation2</groupId>
                <artifactId>android-maven-plugin</artifactId>
                <configuration>
                    <sdk>
                        <platform>19</platform>
                        <path>${env.ANDROID_HOME}/</path>
                    </sdk>
                    <undeployBeforeDeploy>false</undeployBeforeDeploy>
                </configuration>
                <extensions>true</extensions>
            </plugin>

            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                </configuration>
            </plugin>
        </plugins>

        <pluginManagement>
            <plugins>
                <plugin>                                                
                    <groupId>com.jayway.maven.plugins.android.generation2</groupId>
                    <artifactId>android-maven-plugin</artifactId>
                    <version>3.8.2</version>
                    <extensions>true</extensions>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>

    <dependencies>
        <dependency>
            <groupId>android</groupId>
            <artifactId>android</artifactId>
            <version>4.4.2_r3</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>android.support</groupId>
            <artifactId>compatibility-v4</artifactId>
            <version>20.0.0</version>
        </dependency>

        <dependency>
            <groupId>org.androidannotations</groupId>
            <artifactId>androidannotations</artifactId>
            <version>3.0.1</version>
        </dependency>

        <dependency>
            <groupId>com.mcxiaoke.volley</groupId>
            <artifactId>library</artifactId>
            <version>1.0.6</version>
            <type>jar</type>
        </dependency>

        <dependency>
            <groupId>fr.avianey</groupId>
            <artifactId>facebook-android-api</artifactId>
            <version>3.17.1</version>
            <type>aar</type>
        </dependency>

        <dependency>
            <groupId>org.twitter4j</groupId>
            <artifactId>twitter4j-core</artifactId>
            <version>4.0.2</version>
        </dependency>           
    </dependencies>
</project>

如果我使 android 支持 compatibility-v4 依赖项提供范围安装 运行 成功,但是当我 运行 它时应用程序在 运行 时崩溃来自 IntelliJ,因为它无法膨胀 DrawerLayout 视图。

有什么想法吗?

对于任何感兴趣的人,Facebook api 引起了冲突,因为它包含 android 支持 v4。我添加了一个排除项,现在可以使用了。