所以我正在开发一个可以扫描二维码的应用程序。我下载了 ZXing 库,使用 apache ant 构建它以获取 core.jar,将其放在我的项目文件夹中,并将其作为 jar 添加到构建路径中。不,当我尝试执行以下操作时:
Intent intent = new Intent("com.google.zxing.client.android.SCAN");
intent.putExtra("SCAN_MODE", "QR_CODE_MODE");
startActivityForResult(intent, 0);
我收到以下错误:
08-14 18:52:01.191: E/AndroidRuntime(617): FATAL EXCEPTION: main
08-14 18:52:01.191: E/AndroidRuntime(617): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.android.Wowser/com.google.zxing.client.android.CaptureActivity}: java.lang.ClassNotFoundException: com.google.zxing.client.android.CaptureActivity in loader dalvik.system.PathClassLoader[/data/app/com.android.Wowser-1.apk]
08-14 18:52:01.191: E/AndroidRuntime(617): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1569)
08-14 18:52:01.191: E/AndroidRuntime(617): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
08-14 18:52:01.191: E/AndroidRuntime(617): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
08-14 18:52:01.191: E/AndroidRuntime(617): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
08-14 18:52:01.191: E/AndroidRuntime(617): at android.os.Handler.dispatchMessage(Handler.java:99)
08-14 18:52:01.191: E/AndroidRuntime(617): at android.os.Looper.loop(Looper.java:123)
08-14 18:52:01.191: E/AndroidRuntime(617): at android.app.ActivityThread.main(ActivityThread.java:3683)
08-14 18:52:01.191: E/AndroidRuntime(617): at java.lang.reflect.Method.invokeNative(Native Method)
08-14 18:52:01.191: E/AndroidRuntime(617): at java.lang.reflect.Method.invoke(Method.java:507)
08-14 18:52:01.191: E/AndroidRuntime(617): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
08-14 18:52:01.191: E/AndroidRuntime(617): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
08-14 18:52:01.191: E/AndroidRuntime(617): at dalvik.system.NativeStart.main(Native Method)
08-14 18:52:01.191: E/AndroidRuntime(617): Caused by: java.lang.ClassNotFoundException: com.google.zxing.client.android.CaptureActivity in loader dalvik.system.PathClassLoader[/data/app/com.android.Wowser-1.apk]
08-14 18:52:01.191: E/AndroidRuntime(617): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
08-14 18:52:01.191: E/AndroidRuntime(617): at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
08-14 18:52:01.191: E/AndroidRuntime(617): at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
08-14 18:52:01.191: E/AndroidRuntime(617): at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
08-14 18:52:01.191: E/AndroidRuntime(617): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1561)
08-14 18:52:01.191: E/AndroidRuntime(617): ... 11 more
<?xml version="1.0" encoding="utf-8"?>
<uses-sdk android:minSdkVersion="10" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CAMERA"/>
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:name="com.android.Wowser.DealsActivity"
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:configChanges="orientation|keyboardHidden"
android:screenOrientation="landscape"
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>
<activity android:name=".Register" />
<activity android:name=".SignIn" />
<activity android:name=".Options" />
<activity android:name=".Scan" />
</application>
谁能告诉我如何设置 Zxing 以正确使用它或我可能出错的地方?任何帮助是极大的赞赏。