我想在我的 Android 应用程序(IDE Eclipse)中使用slf4j 和 logback 。我已经添加了 jars 文件(slf4j-api-1.7.1 logback-android-1.0.7-1.jar)来在 Eclipse 中构建路径。我尝试使用以下简单的主要活动在 Adv 中启动我的应用程序
import org.slf4j.Logger
import org.slf4j.LoggerFactory
public class MainActivity extends Activity{
private static final Logger logger =
LoggerFactory.getLogger(MainActivity.class);
private void onnCreate(Bundle svedInstanceState){
super.onCreate(savedInstanceState)
logger.debug("MainActivity created");
}
}
我得到了 logcat 捕获的以下错误
10-02 16:03:46.911: I/dalvikvm(619): Could not find method org.slf4j.LoggerFactory.getLogger, referenced from method com.mbm.activity.MainActivity.<clinit>
10-02 16:03:46.911: W/dalvikvm(619): VFY: unable to resolve static method 3250: Lorg/slf4j/LoggerFactory;.getLogger (Ljava/lang/Class;)Lorg/slf4j/Logger;
10-02 16:03:46.941: I/dalvikvm(619): Could not find method org.slf4j.Logger.debug, referenced from method com.mbm.activity.MainActivity.onToggleClicked
10-02 16:03:46.941: W/dalvikvm(619): VFY: unable to resolve interface method 3248: Lorg/slf4j/Logger;.debug (Ljava/lang/String;)V
10-02 16:03:46.941: I/dalvikvm(619): Could not find method org.slf4j.Logger.info, referenced from method com.mbm.activity.MainActivity.onToggleClicked
10-02 16:03:46.941: W/dalvikvm(619): VFY: unable to resolve interface method 3249: Lorg/slf4j/Logger;.info (Ljava/lang/String;)V
10-02 16:03:46.951: W/dalvikvm(619): Exception Ljava/lang/NoClassDefFoundError; thrown while initializing Lcom/mbm/activity/MainActivity;
10-02 16:03:46.951: W/dalvikvm(619): Class init failed in newInstance call (Lcom/mbm/activity/MainActivity;)
10-02 16:03:46.951: W/dalvikvm(619): threadid=1: thread exiting with uncaught exception (group=0x40a13300)
10-02 16:03:46.961: E/AndroidRuntime(619): FATAL EXCEPTION: main
10-02 16:03:46.961: E/AndroidRuntime(619): java.lang.ExceptionInInitializerError
10-02 16:03:46.961: E/AndroidRuntime(619): at java.lang.Class.newInstanceImpl(Native Method)
10-02 16:03:46.961: E/AndroidRuntime(619): at java.lang.Class.newInstance(Class.java:1319)
10-02 16:03:46.961: E/AndroidRuntime(619): at android.app.Instrumentation.newActivity(Instrumentation.java:1053)
10-02 16:03:46.961: E/AndroidRuntime(619): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1974)
10-02 16:03:46.961: E/AndroidRuntime(619): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
10-02 16:03:46.961: E/AndroidRuntime(619): at android.app.ActivityThread.access$600(ActivityThread.java:130)
10-02 16:03:46.961: E/AndroidRuntime(619): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
10-02 16:03:46.961: E/AndroidRuntime(619): at android.os.Handler.dispatchMessage(Handler.java:99)
10-02 16:03:46.961: E/AndroidRuntime(619): at android.os.Looper.loop(Looper.java:137)
10-02 16:03:46.961: E/AndroidRuntime(619): at android.app.ActivityThread.main(ActivityThread.java:4745)
10-02 16:03:46.961: E/AndroidRuntime(619): at java.lang.reflect.Method.invokeNative(Native Method)
10-02 16:03:46.961: E/AndroidRuntime(619): at java.lang.reflect.Method.invoke(Method.java:511)
10-02 16:03:46.961: E/AndroidRuntime(619): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
10-02 16:03:46.961: E/AndroidRuntime(619): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
10-02 16:03:46.961: E/AndroidRuntime(619): at dalvik.system.NativeStart.main(Native Method)
10-02 16:03:46.961: E/AndroidRuntime(619): Caused by: java.lang.NoClassDefFoundError: org.slf4j.LoggerFactory
10-02 16:03:46.961: E/AndroidRuntime(619): at com.mbm.activity.MainActivity.<clinit>(MainActivity.java:41)
10-02 16:03:46.961: E/AndroidRuntime(619): ... 15 more
请帮我。