2014-02-25 41 views
0

我有這個問題,我不明白如何解決。我已經使用Maven在eclipse中導入了一個maps forge項目,但是如果嘗試在設備上加載項目,我會得到這個錯誤。 但我知道那個班是在項目中。我怎麼解決這個問題?Android項目上的NoClassDefFoundError

我正在使用Mapsforge rescue 4.0庫。 我已經使用相同的方法來導入Mapsforge 0.31,一切工作正常。

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

這是應用程序的pom.xml。

<?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

<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

是你使用項目作爲庫? –

+0

這似乎是'org.mapsforge.map.android.graphics.AndroidGraphicFactory'類不可用 –

+0

對不起,我沒有'清楚地解釋我自己。 Mapsforge包含一個示例應用程序,您可以在設備上運行該應用程序以瞭解其工作原理。以前的版本有相同的功能,從來沒有給我的問題。 ü我無法啓動這個應用程序,因爲這個問題 – Bombolo

回答

0

溶液如下:

  1. 下載的5個文件: mapsforge核 mapsforge地圖 mapsforge地圖閱讀器 mapsforge-地圖的Android SVG-的Android
  2. 把那些庫(JAR文件),在項目文件夾
  3. 不是去項目 - >清潔

你並不需要安裝Maven或其他插件。通過Java構建路徑 - >庫 - >添加外部JAR包含庫將不起作用。你需要把它放在libs文件夾中。 如果仍然無法正常工作,請確保更新您的Android工具並重試。

祝你好運:)

相關問題