NoClassDefFoundError的与Mapsforge 0.4.0和EclipseMapsforge、NoClassDefFoundError、Eclipse

2023-09-06 18:11:35 作者:~(≧▽≦)~小鲜肉

我想添加地图视图使用Mapsforge我的应用程序。我也做了以下内容:

I am trying to add a map view to my application using Mapsforge. I have done the following:

在下载JAR文件,将它们放置在库/ 文件夹 mapsforge核-0.4.0.jar mapsforge地图-0.4.0.jar mapsforge地图,Android的0.4.0.jar mapsforge地图阅读器-0.4.0.jar Downloaded jar files and placed them in the libs/ folder mapsforge-core-0.4.0.jar mapsforge-map-0.4.0.jar mapsforge-map-android-0.4.0.jar mapsforge-map-reader-0.4.0.jar

然而,当我跑我的应用程序,它崩溃的第一个电话,从库中的类:

However, when I run my app, it crashes on the first call to a class from the library:

E/AndroidRuntime(21265): java.lang.NoClassDefFoundError: org.mapsforge.map.android.graphics.AndroidGraphicFactory

Android的SDK工具都是以上版本17.没有Maven的参与。

Android SDK tools are all above version 17. No Maven involved.

我一直在寻找一个答案,但无济于事。我已经试过移动的罐子在列表中,清洗项目 - 这和我的事情已经做的是什么正在建议在网络上的精髓。没有什么帮助。

I've been searching for an answer, but to no avail. I've tried moving the jars up in the list, cleaning the project – this and the things I did already are the essence of what's being suggested on the net. Nothing helped.

当我审视斌/ dexedLibs的内容,我注意到,被创建,但几乎是空的,除了清单文件和(在地图罐的情况下)的osmarender资源罐子mapsforge。值得注意的是,的classes.dex文件不存在。该文件夹中的支持Android库包含一个classes.dex文件。

When I examine the contents of bin/dexedLibs, I notice that jars for mapsforge were created but are virtually empty, except for the manifest file and (in the case of the maps jar) the osmarender resources. Notably, the classes.dex file is absent. The Android support library in that folder contains a classes.dex file.

任何线索?

编辑:我检查了原来的jar文件。当看着.class文件,我注意到他们每个人开始 CA FE BA BE 00 00 00 33 ,即在Java 7的格式。

I examined the original jar files. When looking at the .class files, I noticed each of them starts with CA FE BA BE 00 00 00 33, i.e. is in Java 7 format.

据一些我发现在网络上的信息,Java 7的通过Android SDK中不支持。是不是还是这样?这可以解释为什么没有工作,但也让我觉得奇怪,为什么Mapsforge开发者会使用Java 7编译一个罐子是要与Android使用...

According to some of the information I found on the net, Java 7 is not supported by Android SDK. Is that still the case? This would explain why nothing works but would make me wonder why the Mapsforge devs would use Java 7 to compile a jar that is to be used with Android...

推荐答案

NoClassDefFound确实是一个很难的异常来解决,解决方法你可以试试。

NoClassDefFound is really a hard Exception to solve,a workaround you can try.

workaroud:Java构建路径 - > Oeder和导出 - >让河畔3rd.jar上述yourPath / src目录

workaroud: Java Build Path -> Oeder and Export -> make sur 3rd.jar above yourPath/src

我知道支持Android java7目录的,只有当你使用的版本上面的19。

I know android support java7, only when you use the version above 19.