我得到以下例外:
10-27 18:52:54.699: E/AndroidRuntime(23636): FATAL EXCEPTION: main
10-27 18:52:54.699: E/AndroidRuntime(23636): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.project/com.project.activity.QRScannerActivity_}:
android.content.ActivityNotFoundException:
Unable to find explicit activity class {com.project/com.google.zxing.client.android.CaptureActivity}; have you declared this activity in your AndroidManifest.xml?
10-27 18:52:54.699: E/AndroidRuntime(23636): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2308)
10-27 18:52:54.699: E/AndroidRuntime(23636): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2358)
10-27 18:52:54.699: E/AndroidRuntime(23636): at android.app.ActivityThread.access$600(ActivityThread.java:153)
10-27 18:52:54.699: E/AndroidRuntime(23636): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1247)
10-27 18:52:54.699: E/AndroidRuntime(23636): at android.os.Handler.dispatchMessage(Handler.java:99)
10-27 18:52:54.699: E/AndroidRuntime(23636): at android.os.Looper.loop(Looper.java:137)
10-27 18:52:54.699: E/AndroidRuntime(23636): at android.app.ActivityThread.main(ActivityThread.java:5227)
10-27 18:52:54.699: E/AndroidRuntime(23636): at java.lang.reflect.Method.invokeNative(Native Method)
10-27 18:52:54.699: E/AndroidRuntime(23636): at java.lang.reflect.Method.invoke(Method.java:511)
10-27 18:52:54.699: E/AndroidRuntime(23636): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:795)
10-27 18:52:54.699: E/AndroidRuntime(23636): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:562)
10-27 18:52:54.699: E/AndroidRuntime(23636): at dalvik.system.NativeStart.main(Native Method)
10-27 18:52:54.699: E/AndroidRuntime(23636): Caused by: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.project/com.google.zxing.client.android.CaptureActivity}; have you declared this activity in your AndroidManifest.xml?
10-27 18:52:54.699: E/AndroidRuntime(23636): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1618)
10-27 18:52:54.699: E/AndroidRuntime(23636): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1417)
10-27 18:52:54.699: E/AndroidRuntime(23636): at android.app.Activity.startActivityForResult(Activity.java:3370)
10-27 18:52:54.699: E/AndroidRuntime(23636): at android.app.Activity.startActivityForResult(Activity.java:3331)
10-27 18:52:54.699: E/AndroidRuntime(23636): at eu.livotov.zxscan.ZXScanHelper.scan(ZXScanHelper.java:43)
10-27 18:52:54.699: E/AndroidRuntime(23636): at com.project.activity.QRScannerActivity.init(QRScannerActivity.java:23)
10-27 18:52:54.699: E/AndroidRuntime(23636): at com.project.activity.QRScannerActivity_.onViewChanged(QRScannerActivity_.java:71)
10-27 18:52:54.699: E/AndroidRuntime(23636): at org.androidannotations.api.view.OnViewChangedNotifier.notifyViewChanged(OnViewChangedNotifier.java:41)
10-27 18:52:54.699: E/AndroidRuntime(23636): at com.project.activity.QRScannerActivity_.setContentView(QRScannerActivity_.java:42)
10-27 18:52:54.699: E/AndroidRuntime(23636): at com.project.activity.QRScannerActivity_.onCreate(QRScannerActivity_.java:32)
10-27 18:52:54.699: E/AndroidRuntime(23636): at android.app.Activity.performCreate(Activity.java:5104)
10-27 18:52:54.699: E/AndroidRuntime(23636): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
10-27 18:52:54.699: E/AndroidRuntime(23636): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2262)
10-27 18:52:54.699: E/AndroidRuntime(23636): ... 11 more
在致电ZXScanHelper.scan
时。我已将zxscanlib
作为参考库添加到项目中。
在此之前我打电话给:
ZXScanHelper.setCustomScanLayout(R.layout.activity_qrscanner);
遵循https://github.com/LivotovLabs/zxscanlib指南。
在清单中声明:
<activity
android:name="com.google.zxing.client.android.CaptureActivity" >
</activity>