Ionic and phonegap barcode scanner app crash on android

My ionic app uses:

"@ionic-native/barcode-scanner": "^5.19.1",
"phonegap-plugin-barcodescanner": "^8.1.0",

Android app crashes right away when i call barcode.scan funcion. I am doing everything like on the very basic example: https://ionicframework.com/docs/native/barcode-scanner

Note: I am testing this on android7 version at the moment. The phone is not very new but still not very old neither. It crashes right after accepting camera permissions.

There is no err message in catch block or anything, app just crashes. Has anyone experienced this or can help me investigate more logs ?

Upvotes: 1

Views: 1221

Answers (2)

Дмитрий
Дмитрий

Reputation: 1

AndroidManifest.xml:12:9-21:20 Error: android:exported needs to be explicitly specified for element <activity#com.google.zxing.client.android.CaptureActivity>. Apps targeting Android 12 and higher are required to specify an explicit value for android:exported when the corresponding component has an intent filter defined. See https://developer.android.com/guide/topics/manifest/activity-element#exported for details.

Upvotes: 0

I have found the issue, basicly it was missing com.google.zxing.client.android.SCAN from AndroidManifest.xml file:

<activity android:configChanges="orientation|keyboardHidden" android:name="com.google.zxing.client.android.CaptureActivity" 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>

Not sure why the plugin installation did not added anything nor it was described in github, but It was requiring activity for the manifest file.

Upvotes: 1

Related Questions