NoClassDefFoundError with Mapsforge 0.4.0 and Ecli

2019-07-23 16:31发布

问题:

I am trying to setup a new Android project with Mapsforge. I know that people have been getting this issue because the library requires Java 7 to build. However, I am using Build-Tools verson 20, which uses Java 7. I also have the latest updated version of the Eclipse tools. In fact, I am on a clean install of the Android Developer Kit.

So far, I have imported mapsforge-core, mapsforge-map, mapsforge-map-android, mapsforge-map-awt, and mapsforge-map-reader. I then tried to initialize a MapView using the following code:

AndroidGraphicFactory.createInstance(thisApp);

This results in the following error.

java.lang.NoClassDefFoundError: org.mapsforge.map.android.graphics.AndroidGraphicFactory

I looked in the referenced libraries, and the AndroidGraphicFactory class is defined within org.mapsforge.map.android.graphics and shows up. When looking at the jar file within /bin/dexedLibs\, the classes.dex file exists, but there is next to nothing else.

I followed the steps suggested by this answer, but the error persists.

Any ideas as to why this might be?

回答1:

You need put the jar file into the libs/ folder insted of add reference on java build path.