java - 条码扫描仪已停止

标签 java android adt zxing

我正在尝试使用 ZXing 库对条形码扫描仪进行编码。

当我启动我的应用程序时,一切正常。

按下扫描按钮后,我收到一个弹出窗口:“BarCodeScanner 已停止。”

日志猫:

10-12 10:51:57.674: I/PersonaManager(13977): getPersonaService() name persona_policy
10-12 10:51:57.824: I/Adreno-EGL(13977): <qeglDrvAPI_eglInitialize:381>: EGL 1.4 QUALCOMM build: AU_LINUX_ANDROID_KK_2.7_RB1.04.04.02.007.050_msm8960_refs/tags/AU_LINUX_ANDROID_KK_2.7_RB1.04.04.02.007.050__release_AU ()
10-12 10:51:57.824: I/Adreno-EGL(13977): OpenGL ES Shader Compiler Version: 17.01.12.SPL
10-12 10:51:57.824: I/Adreno-EGL(13977): Build Date: 03/28/14 Fri
10-12 10:51:57.824: I/Adreno-EGL(13977): Local Branch: 
10-12 10:51:57.824: I/Adreno-EGL(13977): Remote Branch: refs/tags/AU_LINUX_ANDROID_KK_2.7_RB1.04.04.02.007.050
10-12 10:51:57.824: I/Adreno-EGL(13977): Local Patches: NONE
10-12 10:51:57.824: I/Adreno-EGL(13977): Reconstruct Branch: NOTHING
10-12 10:51:57.864: D/OpenGLRenderer(13977): Enabling debug mode 0
10-12 10:52:01.308: D/AndroidRuntime(13977): Shutting down VM
10-12 10:52:01.318: W/dalvikvm(13977): threadid=1: thread exiting with uncaught exception (group=0x418e9da0)
10-12 10:52:01.318: E/AndroidRuntime(13977): FATAL EXCEPTION: main
10-12 10:52:01.318: E/AndroidRuntime(13977): Process: com.example, PID: 13977
10-12 10:52:01.318: E/AndroidRuntime(13977): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example/com.google.zxing.client.android.CaptureActivity}: java.lang.ClassNotFoundException: Didn't find class "com.google.zxing.client.android.CaptureActivity" on path: DexPathList[[zip file "/data/app/com.example-8.apk"],nativeLibraryDirectories=[/data/app-lib/com.example-8, /vendor/lib, /system/lib]]
10-12 10:52:01.318: E/AndroidRuntime(13977): 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2305)
10-12 10:52:01.318: E/AndroidRuntime(13977): 	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2470)
10-12 10:52:01.318: E/AndroidRuntime(13977): 	at android.app.ActivityThread.access$900(ActivityThread.java:174)
10-12 10:52:01.318: E/AndroidRuntime(13977): 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1307)
10-12 10:52:01.318: E/AndroidRuntime(13977): 	at android.os.Handler.dispatchMessage(Handler.java:102)
10-12 10:52:01.318: E/AndroidRuntime(13977): 	at android.os.Looper.loop(Looper.java:146)
10-12 10:52:01.318: E/AndroidRuntime(13977): 	at android.app.ActivityThread.main(ActivityThread.java:5593)
10-12 10:52:01.318: E/AndroidRuntime(13977): 	at java.lang.reflect.Method.invokeNative(Native Method)
10-12 10:52:01.318: E/AndroidRuntime(13977): 	at java.lang.reflect.Method.invoke(Method.java:515)
10-12 10:52:01.318: E/AndroidRuntime(13977): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283)
10-12 10:52:01.318: E/AndroidRuntime(13977): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
10-12 10:52:01.318: E/AndroidRuntime(13977): 	at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:132)
10-12 10:52:01.318: E/AndroidRuntime(13977): 	at dalvik.system.NativeStart.main(Native Method)
10-12 10:52:01.318: E/AndroidRuntime(13977): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.zxing.client.android.CaptureActivity" on path: DexPathList[[zip file "/data/app/com.example-8.apk"],nativeLibraryDirectories=[/data/app-lib/com.example-8, /vendor/lib, /system/lib]]
10-12 10:52:01.318: E/AndroidRuntime(13977): 	at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:67)
10-12 10:52:01.318: E/AndroidRuntime(13977): 	at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
10-12 10:52:01.318: E/AndroidRuntime(13977): 	at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
10-12 10:52:01.318: E/AndroidRuntime(13977): 	at android.app.Instrumentation.newActivity(Instrumentation.java:1067)
10-12 10:52:01.318: E/AndroidRuntime(13977): 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2296)
10-12 10:52:01.318: E/AndroidRuntime(13977): 	... 12 more

这是我的 list :

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example"
    android:versionCode="1"
    android:versionName="1.0" >
 
    <uses-sdk
        android:minSdkVersion="11"
        android:targetSdkVersion="18" />
 
    <uses-permission android:name="android.permission.CAMERA"/>
     
    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.example.MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
         
        <activity
               android:name="com.google.zxing.client.android.CaptureActivity"
               android:screenOrientation="landscape"
               android:configChanges="orientation|keyboardHidden"
               android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
               android:windowSoftInputMode="stateAlwaysHidden">
               <intent-filter>
                  <action android:name="android.intent.action.MAIN"/>
                  <category android:name="android.intent.category.DEFAULT"/>
               </intent-filter>
               <intent-filter>
                  <action android:name="com.google.zxing.client.android.SCAN"/>
                  <category android:name="android.intent.category.DEFAULT"/>
               </intent-filter>
        </activity>
    </application>
</manifest>

希望你能帮助我。 :)

最佳答案

您必须将 Zxing 作为库导入到您的项目中。通过查看错误,您似乎没有将其作为依赖项添加到您的项目中。如果您使用的是 Eclipse,则将 Zxing 添加为libary 并将该库添加到您的项目中。如果您使用的是 Android Studio

dependencies {
   compile 'com.google.zxing:core:3.0.0'
}

将此行添加到您的 gradle 文件中。

关于java - 条码扫描仪已停止,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26323447/

相关文章:

java - 无法在 dex 路径列表中找到该类

java - 我无法弄清楚我的 NullPointerException 有什么问题,或者它为什么存在

java - 未聚焦组件中的 KeyPressed 和 mousePressed 事件

java - 用程序理解java中的交换函数

java - iText 7 : Paragraph height as it would be rendered

java - 我在 Eclipse 中的 src 文件夹是空的。无法编写应用程序代码

Android Eclipse 问题 Failed to create BuildConfig class

java - Android 获取相对于地平线的角度

java - ExifInterface : Skip the tag entry since tag number is not defined, 压缩图片时

android - ADT 找不到工具目录