本文介绍了对NoClassDefFoundError的Andr​​oid项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个问题,我可以不知道如何解决。我已导入在Eclipse中使用Maven一个地图Forge项目,但如果试图加载在设备项目中,我得到这个错误。
但我知道,那类项目。我怎样才能解决这个问题?

I have this problem that i can't understand how to solve. i have imported a maps forge project in eclipse using maven, but if try to load the project on device, i get this error.But i know that that class is in the project. How can i solve this problem?

我的Mapsforge救援4.0库周转。
我用同样的方法导入Mapsforge 0.31和一切工作正常。

I am working with the Mapsforge rescue 4.0 library.I have used the same method to import Mapsforge 0.31 and everything works fine.

    02-25 16:46:03.202: E/AndroidRuntime(6370): java.lang.NoClassDefFoundError: org.mapsforge.map.android.graphics.AndroidGraphicFactory

这是应用程序的pom.xml中。

This is the pom.xml of the app.

    <?xml version="1.0" encoding="UTF-8"?>

http://maven.apache.org/xsd/maven-4.0.0.xsd>
    4.0.0
    
        org.mapsforge
        mapsforge
        0.4.0-SNAPSHOT
        ../../../pom.xml
    

http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.mapsforge mapsforge 0.4.0-SNAPSHOT ../../../pom.xml

<artifactId>Samples</artifactId>
<packaging>apk</packaging>

<properties>
    <rootDirectory>../../../</rootDirectory>
    <targetJdk>1.6</targetJdk>
</properties>

<build>
    <plugins>
        <plugin>
            <groupId>com.jayway.maven.plugins.android.generation2</groupId>
            <artifactId>android-maven-plugin</artifactId>
            <configuration>
                <dex>
                    <jvmArguments>
                        <jvmArgument>-Xmx512M</jvmArgument>
                    </jvmArguments>
                </dex>
            </configuration>
            <extensions>true</extensions>
        </plugin>

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-eclipse-plugin</artifactId>
            <configuration>
                <useProjectReferences>false</useProjectReferences>
                <buildOutputDirectory>bin/classes</buildOutputDirectory>
                <additionalBuildcommands>
                    <buildcommand>com.android.ide.eclipse.adt.ResourceManagerBuilder</buildcommand>
                    <buildcommand>com.android.ide.eclipse.adt.PreCompilerBuilder</buildcommand>
                    <buildcommand>com.android.ide.eclipse.adt.ApkBuilder</buildcommand>
                    <buildcommand>org.eclipse.jdt.core.javabuilder</buildcommand>
                </additionalBuildcommands>
                <additionalProjectnatures>
                    <projectnature>org.eclipse.jdt.core.javanature</projectnature>
                    <projectnature>com.android.ide.eclipse.adt.AndroidNature</projectnature>
                </additionalProjectnatures>
                <classpathContainers>
                    <classpathContainer>org.eclipse.jdt.launching.JRE_CONTAINER</classpathContainer>
                    <classpathContainer>com.android.ide.eclipse.adt.ANDROID_FRAMEWORK</classpathContainer>
                    <classpathContainer>com.android.ide.eclipse.adt.LIBRARIES</classpathContainer>
                    <classpathContainer>com.android.ide.eclipse.adt.DEPENDENCIES</classpathContainer>
                </classpathContainers>
                <excludes>
                    <exclude>com.google.android:android</exclude>
                    <exclude>org.apache.httpcomponents:httpclient</exclude>
                    <exclude>org.apache.httpcomponents:httpcore</exclude>
                    <exclude>commons-codec:commons-codec</exclude>
                    <exclude>commons-logging:commons-logging</exclude>
                    <exclude>org.json:json</exclude>
                    <exclude>org.khronos:opengl-api</exclude>
                    <exclude>xerces:xmlParserAPIs</exclude>
                    <exclude>xpp3:xpp3</exclude>
                </excludes>
            </configuration>
        </plugin>
    </plugins>
</build>

<dependencies>
    <dependency>
        <groupId>org.mapsforge</groupId>
        <artifactId>mapsforge-map-android</artifactId>
        <type>apklib</type>
        <version>${project.version}</version>
    </dependency>

    <dependency>
        <groupId>android</groupId>
        <artifactId>android</artifactId>
        <version>4.4.2_r2</version>
        <scope>provided</scope>
    </dependency>

    <dependency>
        <groupId>com.jayway.android.robotium</groupId>
        <artifactId>robotium-solo</artifactId>
        <version>5.0.1</version>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>com.google.android</groupId>
        <artifactId>support-v4</artifactId>
        <version>r7</version>
    </dependency>
</dependencies>

推荐答案

解决方法如下:


  1. 下载的5个文件:
    mapsforge核心
    mapsforge地图
    mapsforge地图阅读器
    mapsforge地图,安卓
    SVG-的Andr​​oid

  2. 把这些库(JAR文件)项目文件夹中的

  3. 不是去项目 - >清除

您不需要安装Maven或其他插件。包括通过Java构建路径库 - >图书馆 - >添加外部JAR将无法工作。你需要把它放在libs文件夹。
如果仍然不能正常工作,请确保您更新Android工具,然后重试。

You don't need to install Maven or other plugins. Including the libraries through Java Build Path -> Libraries -> Add External JARs won't work. You need to put it in the libs folder.If it still doesn't work, make sure you update your android tools and try again.

祝你好运:)

这篇关于对NoClassDefFoundError的Andr​​oid项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-17 14:34