phonegap / phonegap-plugin-barcodescanner

cross-platform BarcodeScanner for Cordova / PhoneGap
MIT License
1.27k stars 1.39k forks source link

App crashes in android #856

Closed akashkumar-cgvak closed 4 years ago

akashkumar-cgvak commented 4 years ago

Expected Behaviour

Tried to scan QR code in Ionic app

Actual Behaviour

Works fine in iphone but the app crashes while opening the scanner in android

Reproduce Scenario (including but not limited to)

Try to open the barcode scanner

Steps to Reproduce

Try to open the barcode scanner

Platform and Version (eg. Android 5.0 or iOS 9.2.1)

Android 8.0

(Android) What device vendor (e.g. Samsung, HTC, Sony...)

Samsung

Cordova CLI version and cordova platform version

9.0.0 (cordova-lib@9.0.1) cordova --version cordova platforms

Plugin version

8.1.0 cordova plugin version | grep phonegap-plugin-barcodescanner

Sample Code that illustrates the problem

this.barcodeScanner .scan() .then(barcodeData => { console.log(JSON.stringify(barcodeData)); alert("Barcode data " + JSON.stringify(barcodeData)); // this.scannedData = barcodeData; }) .catch(err => { console.log("Error", err); });

Logs taken while reproducing problem

No logs printed

sabi1981 commented 4 years ago

Had to add the following :

    <config-file parent="/manifest/application" target="AndroidManifest.xml">
        <activity android:clearTaskOnLaunch="true" android:configChanges="orientation|keyboardHidden" android:exported="false" android:name="com.google.zxing.client.android.CaptureActivity" android:screenOrientation="portrait" android:theme="@android:style/Theme.NoTitleBar.Fullscreen" android:windowSoftInputMode="stateAlwaysHidden">
            <intent-filter>
                <action android:name="com.phonegap.plugins.barcodescanner.SCAN" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>
    </config-file>

However, this generated an error, duplicate entries in AndroidManifest.xml :

platforms\android\app\src\main\AndroidManifest.xml:20:9-25:20 Error:
    Element activity#com.google.zxing.client.android.CaptureActivity at AndroidManifest.xml:20:9-25:20 duplicated with element declared at AndroidManifest.xml:12:9-311
platforms\android\app\src\main\AndroidManifest.xml Error:
    Validation failed, exiting

And in AndroidManifest.xml :

   <activity android:clearTaskOnLaunch="true" android:configChanges="orientation|keyboardHidden|screenSize" android:exported="false" android:name="com.google.zxing.client.android.CaptureActivity" android:theme="@android:style/Theme.NoTitleBar.Fullscreen" android:windowSoftInputMode="stateAlwaysHidden" />

   <activity android:clearTaskOnLaunch="true" android:configChanges="orientation|keyboardHidden" android:exported="false" android:name="com.google.zxing.client.android.CaptureActivity" android:screenOrientation="portrait" android:theme="@android:style/Theme.NoTitleBar.Fullscreen" android:windowSoftInputMode="stateAlwaysHidden">
        <intent-filter>
            <action android:name="com.phonegap.plugins.barcodescanner.SCAN" />
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>

Still looking for the solution as either nothing in AndroidManifest.xml or duplicated entries....

lock[bot] commented 4 years ago

This thread has been automatically locked.