2014-10-12 94 views
1

我正在嘗試使用ZXing庫對我的條碼掃描器進行編碼。BarCodeScanner已停止

當我開始我的應用程序時一切正常。

按下掃描按鈕後,我得到一個彈出窗口:「BarCodeScanner已停止。」

的logcat:

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): \t at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2305) 
 
10-12 10:52:01.318: E/AndroidRuntime(13977): \t at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2470) 
 
10-12 10:52:01.318: E/AndroidRuntime(13977): \t at android.app.ActivityThread.access$900(ActivityThread.java:174) 
 
10-12 10:52:01.318: E/AndroidRuntime(13977): \t at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1307) 
 
10-12 10:52:01.318: E/AndroidRuntime(13977): \t at android.os.Handler.dispatchMessage(Handler.java:102) 
 
10-12 10:52:01.318: E/AndroidRuntime(13977): \t at android.os.Looper.loop(Looper.java:146) 
 
10-12 10:52:01.318: E/AndroidRuntime(13977): \t at android.app.ActivityThread.main(ActivityThread.java:5593) 
 
10-12 10:52:01.318: E/AndroidRuntime(13977): \t at java.lang.reflect.Method.invokeNative(Native Method) 
 
10-12 10:52:01.318: E/AndroidRuntime(13977): \t at java.lang.reflect.Method.invoke(Method.java:515) 
 
10-12 10:52:01.318: E/AndroidRuntime(13977): \t at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283) 
 
10-12 10:52:01.318: E/AndroidRuntime(13977): \t at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099) 
 
10-12 10:52:01.318: E/AndroidRuntime(13977): \t at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:132) 
 
10-12 10:52:01.318: E/AndroidRuntime(13977): \t 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): \t at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:67) 
 
10-12 10:52:01.318: E/AndroidRuntime(13977): \t at java.lang.ClassLoader.loadClass(ClassLoader.java:497) 
 
10-12 10:52:01.318: E/AndroidRuntime(13977): \t at java.lang.ClassLoader.loadClass(ClassLoader.java:457) 
 
10-12 10:52:01.318: E/AndroidRuntime(13977): \t at android.app.Instrumentation.newActivity(Instrumentation.java:1067) 
 
10-12 10:52:01.318: E/AndroidRuntime(13977): \t at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2296) 
 
10-12 10:52:01.318: E/AndroidRuntime(13977): \t ... 12 more

這裏是我的清單:

<?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>

我希望你能幫助我。 :)

+0

發佈您的清單文件 – goonerDroid 2014-10-12 09:09:45

+0

Manifest在第一篇文章中。 – Aland 2014-10-12 10:57:21

+0

您是否在您測試此應用的設備上安裝了ZXING應用? – Nabin 2014-10-12 11:00:49

回答

0

您必須將Zxing作爲庫導入到您的項目中。通過查看錯誤,您似乎並未將其作爲依賴項添加到項目中。如果您使用的是Eclipse,那麼將Zxing添加爲libary並添加圖書館到您的項目。如果您正在使用Android Studio

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

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

+0

謝謝!我可能猜到了。 :) – Aland 2014-10-15 18:53:31