我正在使用 Magtek 磁卡读卡器并通过 USB 将该 MCR 与 android 设备连接。当我使用 API 12 及更高版本时,它工作正常,但是当我将 API 版本更改为 8 时,它崩溃并在 Log cat 中显示以下结果:
04-12 11:39:39.560: E/AndroidRuntime(276): java.lang.NoClassDefFoundError: android.hardware.usb.UsbManager
04-12 11:39:39.560: E/AndroidRuntime(276): at com.magtek.mobile.android.libDynamag.MagTeklibDynamag.openDevice(MagTeklibDynamag.java:98)
04-12 11:39:39.560: E/AndroidRuntime(276): at com.magtek.mobile.android.MagTekDemo.Dynamag.MagTekDemo.onResume(MagTekDemo.java:119)
04-12 11:39:39.560: E/AndroidRuntime(276): at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1149)
04-12 11:39:39.560: E/AndroidRuntime(276): at android.app.Activity.performResume(Activity.java:3823)
04-12 11:39:39.560: E/AndroidRuntime(276): at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3118)
04-12 11:39:39.560: E/AndroidRuntime(276): at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3143)
04-12 11:39:39.560: E/AndroidRuntime(276): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2684)
04-12 11:39:39.560: E/AndroidRuntime(276): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
04-12 11:39:39.560: E/AndroidRuntime(276): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
04-12 11:39:39.560: E/AndroidRuntime(276): at android.os.Handler.dispatchMessage(Handler.java:99)
04-12 11:39:39.560: E/AndroidRuntime(276): at android.os.Looper.loop(Looper.java:123)
04-12 11:39:39.560: E/AndroidRuntime(276): at android.app.ActivityThread.main(ActivityThread.java:4627)
04-12 11:39:39.560: E/AndroidRuntime(276): at java.lang.reflect.Method.invokeNative(Native Method)
04-12 11:39:39.560: E/AndroidRuntime(276): at java.lang.reflect.Method.invoke(Method.java:521)
04-12 11:39:39.560: E/AndroidRuntime(276): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
04-12 11:39:39.560: E/AndroidRuntime(276): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
04-12 11:39:39.560: E/AndroidRuntime(276): at dalvik.system.NativeStart.main(Native Method)
那么我们可以让 Android 2.2 USB 启用并使用 USB 设备吗?