2

我正在尝试创建一个应用程序来测试如何使用OpenStreetMapsAPI,但是当我插入 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.jarosmdroid-third-party-3.0.8.jar

任何帮助都会很棒

4

2 回答 2

1

是的,你还需要一个罐子

NoClassDefFoundError: org.slf4j.LoggerFactory 

给你线索

slf4j-android-1.5.8.jar 是你需要的jar

编辑:

现在似乎有更高版本(1.6.6),可在: latest slf4j

于 2012-07-05T18:54:20.227 回答
0

是的,你还需要一个 jar 来解决这个 NoClassDefFoundError: org.slf4j.LoggerFactory错误

http://www.slf4j.org/android/并且 jar 的名称是slf4j-android-1.6.1-RC1.jar [sha1]

于 2015-09-28T09:48:42.443 回答