我正在尝试使用ZXing Library对我的条形码扫描器进行编码。
当我启动我的应用程序时,一切正常。
按下扫描按钮后,我收到一个弹出窗口:“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): 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
这是我的清单:
<?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 :(得分:0)
您必须将Zxing
作为库导入到您的项目中。通过查看错误,您似乎不会将依赖项添加到项目中。如果您使用的是Eclipse,则将Zxing添加为libary并添加该库是您的项目。如果您使用的是Android Studio
dependencies {
compile 'com.google.zxing:core:3.0.0'
}
在您的gradle文件中添加此行。