maven-android-plugin,java.lang.NoClassDefFoundError

时间:2013-08-12 15:26:10

标签: android eclipse maven robospice

我尝试对我的Android项目进行编组。我使用robospice作为我的依赖之一。编译运行正常,但在启动应用程序后出现以下错误:

08-12 17:06:56.040: E/AndroidRuntime(15969): java.lang.NoClassDefFoundError: com.octo.android.robospice.SpiceManager

的pom.xml:

<properties>
    <android.version>4.2.2</android.version>
    <android-support.version>r6</android-support.version>
    <robospice.version>1.4.6</robospice.version>
    <robospice-google-http-client.version>1.3.0</robospice-google-http-client.version>
    <google-http-client-jackson.version>1.16.0-rc</google-http-client-jackson.version>
    <robospice-spring-android.version>1.4.6</robospice-spring-android.version>
    <spring.android.jackson.version>1.9.11</spring.android.jackson.version>
    <commons.logging.version>1.1.3</commons.logging.version>
    <android-maven-plugin.version>3.5.0</android-maven-plugin.version>
    <maven-compiler-plugin.version>2.3.2</maven-compiler-plugin.version>
    <maven-clean-plugin.version>2.5</maven-clean-plugin.version>
    <maven-dependency-plugin.version>2.6</maven-dependency-plugin.version>
    <android.sdk.path>${env.ANDROID_HOME}/</android.sdk.path>
    <android.sdk.platform>17</android.sdk.platform>
</properties>

<dependencies>

    <dependency>
        <groupId>com.google.android</groupId>
        <artifactId>support-v4</artifactId>
        <version>${android-support.version}</version>
    </dependency>
    <dependency>
        <groupId>com.octo.android.robospice</groupId>
        <artifactId>robospice</artifactId>
        <version>${robospice.version}</version>
    </dependency>
    <dependency>
        <groupId>com.octo.android.robospice</groupId>
        <artifactId>robospice-google-http-client</artifactId>
        <version>${robospice-google-http-client.version}</version>
        <type>jar</type>
        <exclusions>
            <exclusion>
                <groupId>xpp3</groupId>
                <artifactId>xpp3</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>com.google.http-client</groupId>
        <artifactId>google-http-client-jackson</artifactId>
        <version>${google-http-client-jackson.version}</version>
        <exclusions>
            <exclusion>
                <groupId>xpp3</groupId>
                <artifactId>xpp3</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>com.octo.android.robospice</groupId>
        <artifactId>robospice-spring-android</artifactId>
        <version>${robospice-spring-android.version}</version>
    </dependency>
    <dependency>
        <groupId>com.google.api-client</groupId>
        <artifactId>google-api-client-android</artifactId>
        <version>1.16.0-rc</version>
        <exclusions>
            <exclusion>
                <groupId>xpp3</groupId>
                <artifactId>xpp3</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>com.octo.android.robospice</groupId>
        <artifactId>robospice-cache</artifactId>
        <version>1.4.6</version>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>com.jayway.maven.plugins.android.generation2</groupId>
            <artifactId>maven-android-plugin</artifactId>
            <inherited>true</inherited>

            <configuration>
                <androidManifestFile>${project.basedir}/AndroidManifest.xml</androidManifestFile>
                <sourceDirectory>${project.basedir}/src</sourceDirectory>
                <assetsDirectory>${project.basedir}/assets</assetsDirectory>
                <resourceDirectory>${project.basedir}/res</resourceDirectory>
                <nativeLibrariesDirectory>${project.basedir}/src/main/native</nativeLibrariesDirectory>
                <sdk>
                    <path>${android.sdk.path}</path>
                    <platform>${android.sdk.platform}</platform>
                </sdk>
                <undeployBeforeDeploy>true</undeployBeforeDeploy>
                <device>usb</device>
            </configuration>

            <extensions>true</extensions>
        </plugin>

        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <source>1.6</source>
                <target>1.6</target>
            </configuration>
        </plugin>
    </plugins>
</build>

我已经为M2E安装了Android配置器。我在Java Build Path中的属性 - &gt;订单和导出包括Maven依赖项(已选中)。

如何解决这个问题?

1 个答案:

答案 0 :(得分:0)

我通过从头创建新项目(使用此处定义的原型之一https://github.com/akquinet/android-archetypes)并迁移旧代码来解决此问题。