我正在尝试创建一个应用程序来测试如何使用OpenStreetMaps
API,但是当我插入 jar 文件时出现错误提示NoClassDefFoundError
堆栈跟踪
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
我的活动就这么简单
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;
}
}
一旦尝试创建地图视图,它就会失败,我想还有另一个 jar 文件吗?目前我有,osmdroid-android-3.0.8.jar
虽然我可能不需要最后两个来实际创建地图。osmdroid-packager-3.0.8.jar
osmdroid-third-party-3.0.8.jar
任何帮助都会很棒