我在尝试集成ZXing以在我的Android应用中扫描DataMatrix代码时遇到以下错误:
06-16 13:25:54.004: E/AndroidRuntime(32515): FATAL EXCEPTION: main
06-16 13:25:54.004: E/AndroidRuntime(32515): Process: com.myApp, PID: 32515
06-16 13:25:54.004: E/AndroidRuntime(32515): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.myApp/com.google.zxing.client.android.CaptureActivity}: android.view.InflateException: Binary XML file line #2: Error inflating class accelerateInterpolator
06-16 13:25:54.004: E/AndroidRuntime(32515): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2505)
06-16 13:25:54.004: E/AndroidRuntime(32515): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2565)
06-16 13:25:54.004: E/AndroidRuntime(32515): at android.app.ActivityThread.access$900(ActivityThread.java:150)
06-16 13:25:54.004: E/AndroidRuntime(32515): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1395)
06-16 13:25:54.004: E/AndroidRuntime(32515): at android.os.Handler.dispatchMessage(Handler.java:102)
06-16 13:25:54.004: E/AndroidRuntime(32515): at android.os.Looper.loop(Looper.java:168)
06-16 13:25:54.004: E/AndroidRuntime(32515): at android.app.ActivityThread.main(ActivityThread.java:5821)
06-16 13:25:54.004: E/AndroidRuntime(32515): at java.lang.reflect.Method.invoke(Native Method)
06-16 13:25:54.004: E/AndroidRuntime(32515): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:797)
06-16 13:25:54.004: E/AndroidRuntime(32515): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:687)
06-16 13:25:54.004: E/AndroidRuntime(32515): Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class accelerateInterpolator
06-16 13:25:54.004: E/AndroidRuntime(32515): at android.preference.GenericInflater.createItemFromTag(GenericInflater.java:443)
06-16 13:25:54.004: E/AndroidRuntime(32515): at android.preference.GenericInflater.inflate(GenericInflater.java:318)
06-16 13:25:54.004: E/AndroidRuntime(32515): at android.preference.GenericInflater.inflate(GenericInflater.java:264)
06-16 13:25:54.004: E/AndroidRuntime(32515): at android.preference.PreferenceManager.inflateFromResource(PreferenceManager.java:273)
06-16 13:25:54.004: E/AndroidRuntime(32515): at android.preference.PreferenceManager.setDefaultValues(PreferenceManager.java:486)
06-16 13:25:54.004: E/AndroidRuntime(32515): at android.preference.PreferenceManager.setDefaultValues(PreferenceManager.java:445)
06-16 13:25:54.004: E/AndroidRuntime(32515): at com.google.zxing.client.android.CaptureActivity.onCreate(CaptureActivity.java:143)
06-16 13:25:54.004: E/AndroidRuntime(32515): at android.app.Activity.performCreate(Activity.java:6262)
06-16 13:25:54.004: E/AndroidRuntime(32515): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1125)
06-16 13:25:54.004: E/AndroidRuntime(32515): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2458)
06-16 13:25:54.004: E/AndroidRuntime(32515): ... 9 more
06-16 13:25:54.004: E/AndroidRuntime(32515): Caused by: java.lang.ClassNotFoundException: Didn't find class "android.preference.accelerateInterpolator" on path: DexPathList[[zip file "/data/app/com.myApp-1/base.apk"],nativeLibraryDirectories=[/data/app/com.myApp-1/lib/arm, /data/app/com.myApp-1/base.apk!/lib/armeabi, /vendor/lib, /system/lib]]
06-16 13:25:54.004: E/AndroidRuntime(32515): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
06-16 13:25:54.004: E/AndroidRuntime(32515): at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
06-16 13:25:54.004: E/AndroidRuntime(32515): at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
06-16 13:25:54.004: E/AndroidRuntime(32515): at android.preference.GenericInflater.createItem(GenericInflater.java:376)
06-16 13:25:54.004: E/AndroidRuntime(32515): at android.preference.GenericInflater.onCreateItem(GenericInflater.java:419)
06-16 13:25:54.004: E/AndroidRuntime(32515): at android.preference.GenericInflater.createItemFromTag(GenericInflater.java:430)
06-16 13:25:54.004: E/AndroidRuntime(32515): ... 18 more
06-16 13:25:54.004: E/AndroidRuntime(32515): Suppressed: java.lang.ClassNotFoundException: android.preference.accelerateInterpolator
06-16 13:25:54.004: E/AndroidRuntime(32515): at java.lang.Class.classForName(Native Method)
06-16 13:25:54.004: E/AndroidRuntime(32515): at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
06-16 13:25:54.004: E/AndroidRuntime(32515): at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
06-16 13:25:54.004: E/AndroidRuntime(32515): at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
06-16 13:25:54.004: E/AndroidRuntime(32515): ... 22 more
06-16 13:25:54.004: E/AndroidRuntime(32515): Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available
要添加条形码扫描功能,我遵循this教程,因为该应用程序适用于企业环境,因此额外安装的扫描应用程序不适用。
显然,缺少类的接口包加速器是错误的,应该是android.view.animation.accelerateInterpolator(而不是android.preferences.accelerateInterpolator)。 由于这个类没有被我自己的代码调用,所以我不知道这个不正确的路径来自何处以及如何纠正它。