I am using zxing library, where I have built ZXing Android using Eclipse and included ZXing Android into my project
and the poject manifest is
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="phoenix.metro.uis"
android:versionCode="4"
android:versionName="1.2" >
<uses-sdk android:minSdkVersion="8" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application
android:icon="@drawable/metro"
android:label="@string/app_name"
android:theme="@android:style/Theme.NoTitleBar" >
<activity
android:name="MainActivity"
android:label="@string/app_name"
android:screenOrientation="portrait" >
</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=".PhoenixSplashActivity" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="SearchActivity"
android:multiprocess="false"
android:screenOrientation="portrait" >
</activity>
<activity
android:name="OffersActivity"
android:screenOrientation="portrait" >
</activity>
<activity
android:name=".CartsActivity"
android:screenOrientation="portrait" >
</activity>
<activity
android:name="GANDActivity"
android:screenOrientation="portrait" >
</activity>
<activity
android:name="MetroActivity"
android:screenOrientation="portrait" >
</activity>
<activity android:name="AddItemActivity" >
</activity>
<activity
android:name=".AboutUsActivity"
android:screenOrientation="portrait" >
</activity>
</application>
</manifest>
but I get the exception :
10-01 23:00:29.227: W/CaptureActivity(539): android.content.pm.PackageManager$NameNotFoundException: com.google.zxing.client.android
10-01 23:00:29.227: W/CaptureActivity(539): at android.app.ContextImpl$ApplicationPackageManager.getPackageInfo(ContextImpl.java:1682)
10-01 23:00:29.227: W/CaptureActivity(539): at com.google.zxing.client.android.CaptureActivity.showHelpOnFirstLaunch(CaptureActivity.java:693)
10-01 23:00:29.227: W/CaptureActivity(539): at com.google.zxing.client.android.CaptureActivity.onCreate(CaptureActivity.java:169)
10-01 23:00:29.227: W/CaptureActivity(539): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
10-01 23:00:29.227: W/CaptureActivity(539): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
10-01 23:00:29.227: W/CaptureActivity(539): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
10-01 23:00:29.227: W/CaptureActivity(539): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
10-01 23:00:29.227: W/CaptureActivity(539): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
10-01 23:00:29.227: W/CaptureActivity(539): at android.os.Handler.dispatchMessage(Handler.java:99)
10-01 23:00:29.227: W/CaptureActivity(539): at android.os.Looper.loop(Looper.java:123)
10-01 23:00:29.227: W/CaptureActivity(539): at android.app.ActivityThread.main(ActivityThread.java:3683)
10-01 23:00:29.227: W/CaptureActivity(539): at java.lang.reflect.Method.invokeNative(Native Method)
10-01 23:00:29.227: W/CaptureActivity(539): at java.lang.reflect.Method.invoke(Method.java:507)
10-01 23:00:29.227: W/CaptureActivity(539): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
10-01 23:00:29.227: W/CaptureActivity(539): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
10-01 23:00:29.227: W/CaptureActivity(539): at dalvik.system.NativeStart.main(Native Method)
Reason of the issue is in the
showHelpOnFirstLaunch()method in CaptureActivity. It tries to get version ofcom.google.zxing.client.androidpackage, doesn’t find it and throws the exception. It must be catched bycatch (PackageManager.NameNotFoundException e) { ... }. I don’t know why exception is not catched.You can edit
showHelpOnFirstLaunch()method, e.g. remove the checking of package version or add exception catching if you haven’t it in your version.