I am trying to create an application to test how to use OpenStreetMaps API but when I insert the jar file I get errors saying NoClassDefFoundError
stack trace
07-05 13:35:43.875: E/AndroidRuntime(9235): FATAL EXCEPTION: main
07-05 13:35:43.875: E/AndroidRuntime(9235): java.lang.ExceptionInInitializerError
07-05 13:35:43.875: E/AndroidRuntime(9235): at com.example.osm.test.MainActivity.onCreate(MainActivity.java:16)
07-05 13:35:43.875: E/AndroidRuntime(9235): at android.app.Activity.performCreate(Activity.java:5008)
07-05 13:35:43.875: E/AndroidRuntime(9235): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
07-05 13:35:43.875: E/AndroidRuntime(9235): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
07-05 13:35:43.875: E/AndroidRuntime(9235): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
07-05 13:35:43.875: E/AndroidRuntime(9235): at android.app.ActivityThread.access$600(ActivityThread.java:130)
07-05 13:35:43.875: E/AndroidRuntime(9235): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
07-05 13:35:43.875: E/AndroidRuntime(9235): at android.os.Handler.dispatchMessage(Handler.java:99)
07-05 13:35:43.875: E/AndroidRuntime(9235): at android.os.Looper.loop(Looper.java:137)
07-05 13:35:43.875: E/AndroidRuntime(9235): at android.app.ActivityThread.main(ActivityThread.java:4745)
07-05 13:35:43.875: E/AndroidRuntime(9235): at java.lang.reflect.Method.invokeNative(Native Method)
07-05 13:35:43.875: E/AndroidRuntime(9235): at java.lang.reflect.Method.invoke(Method.java:511)
07-05 13:35:43.875: E/AndroidRuntime(9235): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
07-05 13:35:43.875: E/AndroidRuntime(9235): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
07-05 13:35:43.875: E/AndroidRuntime(9235): at dalvik.system.NativeStart.main(Native Method)
07-05 13:35:43.875: E/AndroidRuntime(9235): Caused by: java.lang.NoClassDefFoundError: org.slf4j.LoggerFactory
07-05 13:35:43.875: E/AndroidRuntime(9235): at org.osmdroid.views.MapView.<clinit>(MapView.java:64)
07-05 13:35:43.875: E/AndroidRuntime(9235): ... 15 more
my Activity is as simple as this
public class MainActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
MapView mapView = new MapView(this,256); //fails
mapView.setClickable(true);
mapView.setBuiltInZoomControls(true);
setContentView(mapView);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
}
it fails as soon as it trys to create the mapview, is there another jar file I am suppose to have? currently I have osmdroid-android-3.0.8.jar, osmdroid-packager-3.0.8.jar and osmdroid-third-party-3.0.8.jar though i probably dont need the last 2 to actually create the map.
any help would be great
Yes, you need one more jar
gives you the clue
slf4j-android-1.5.8.jar is the jar you need
Edit:
It seems like there’s a later (1.6.6) version now, available at:
latest slf4j