Problems with ionic QR code reader [closed]

closed. this question is out of scope and is not currently accepting answers.

want to improve this question? Update the question so it's on-topic for Stack Overflow.

Closed 1 year ago .

improve this question

I'm using the plugin cordova-plugin-qrscanner but when I do all the steps and try to generate the application it generates the error:

See http://g.co/androidstudio/manifest-merger for more information about the manifest merger.

22 actionable tasks: 1 executed, 21 up-to-date
/home/renanrodrigues/projects/applications/rdoe/platforms/android/app/src/main/AndroidManifest.xml:21:5-90 Error:
        Element uses-permission#android.permission.CAMERA at AndroidManifest.xml:21:5-90 duplicated with element declared at AndroidManifest.xml:16:5-65
/home/renanrodrigues/projects/applications/rdoe/platforms/android/app/src/main/AndroidManifest.xml:22:5-85 Error:
        Element uses-feature#android.hardware.camera at AndroidManifest.xml:22:5-85 duplicated with element declared at AndroidManifest.xml:18:5-84
/home/renanrodrigues/projects/applications/rdoe/platforms/android/app/src/main/AndroidManifest.xml Error:
        Validation failed, exiting

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:processDebugManifest'.
> Manifest merger failed with multiple errors, see logs

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 8s
/home/renanrodrigues/projects/applications/rdoe/platforms/android/gradlew: Command failed with exit code 1 Error output:
/home/renanrodrigues/projects/applications/rdoe/platforms/android/app/src/main/AndroidManifest.xml:21:5-90 Error:
        Element uses-permission#android.permission.CAMERA at AndroidManifest.xml:21:5-90 duplicated with element declared at AndroidManifest.xml:16:5-65
/home/renanrodrigues/projects/applications/rdoe/platforms/android/app/src/main/AndroidManifest.xml:22:5-85 Error:
        Element uses-feature#android.hardware.camera at AndroidManifest.xml:22:5-85 duplicated with element declared at AndroidManifest.xml:18:5-84
/home/renanrodrigues/projects/applications/rdoe/platforms/android/app/src/main/AndroidManifest.xml Error:
        Validation failed, exiting

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:processDebugManifest'.
> Manifest merger failed with multiple errors, see logs

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 8s
[ERROR] An error occurred while running subprocess cordova.

        cordova build android --device exited with exit code 1.

Is giving error in File AndroidManifest.xml

<manifest android:hardwareAccelerated="true" android:versionCode="1" android:versionName="0.0.1" package="io.ionic.starter" xmlns:android="http://schemas.android.com/apk/res/android">
    <supports-screens android:anyDensity="true" android:largeScreens="true" android:normalScreens="true" android:resizeable="true" android:smallScreens="true" android:xlargeScreens="true" />
    <uses-permission android:name="android.permission.INTERNET" />
    <application android:hardwareAccelerated="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:supportsRtl="true">
        <activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|smallestScreenSize|screenLayout|uiMode" android:label="@string/activity_name" android:launchMode="singleTop" android:name="MainActivity" android:theme="@android:style/Theme.DeviceDefault.NoActionBar" android:windowSoftInputMode="adjustResize">
            <intent-filter android:label="@string/launcher_name">
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <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:label="Share" android:name="com.google.zxing.client.android.encode.EncodeActivity" />
    </application>
    <uses-permission android:name="android.permission.RECORD_AUDIO" />
    <uses-permission android:name="android.permission.CAMERA" />
    <uses-permission android:name="android.permission.FLASHLIGHT" />
    <uses-feature android:name="android.hardware.camera" android:required="true" />
    <uses-permission android:name="android.permission.NFC" />
    <uses-feature android:name="android.hardware.nfc" android:required="false" />
    <uses-permission android:name="android.permission.CAMERA" android:required="false" />
    <uses-feature android:name="android.hardware.camera" android:required="false" />
    <uses-feature android:name="android.hardware.camera.front" android:required="false" />
</manifest>

When I give up the plugins of both cordova and ionic, it returns everything to normal and so I can do the build.

If this plugin does not have portability for:

Cordova version 9.0.0 ([email protected])

Ionic-CLI version 5.4.4

QR Scanner "cordova-plugin-qrscanner": "^3.0.1"

What other solution can I use ?

Author: Guilherme Nascimento, 2019-10-28

2 answers

The error reports that the configuration is duplicated:

/home/renanrodrigues/projects/applications/rdoe/platforms/android/gradlew: Command failed with exit code 1 Error output:
/home/renanrodrigues/projects/applications/rdoe/platforms/android/app/src/main/AndroidManifest.xml:21:5-90 Error:
        Element uses-permission#android.permission.CAMERA at AndroidManifest.xml:21:5-90 duplicated with element declared at AndroidManifest.xml:16:5-65
/home/renanrodrigues/projects/applications/rdoe/platforms/android/app/src/main/AndroidManifest.xml:22:5-85 Error:
        Element uses-feature#android.hardware.camera at AndroidManifest.xml:22:5-85 duplicated with element declared at AndroidManifest.xml:18:5-84
/home/renanrodrigues/projects/applications/rdoe/platforms/android/app/src/main/AndroidManifest.xml

See:

Element uses-permission#android.permission.CAMERA at AndroidManifest.xml:21:5-90 duplicated with element declared at AndroidManifest.xml:16:5-65

Element uses-feature#android.hardware.camera at AndroidManifest.xml:22:5-85 duplicated with element declared at AndroidManifest.xml:18:5-84

See that you have two permissions on android.permission.CAMERA:

<uses-permission android:name="android.permission.CAMERA" /> <!-- DUPLICADO -->
<uses-permission android:name="android.permission.FLASHLIGHT" />
<uses-feature android:name="android.hardware.camera" android:required="true" />
<uses-permission android:name="android.permission.NFC" />
<uses-feature android:name="android.hardware.nfc" android:required="false" />
<uses-permission android:name="android.permission.CAMERA" android:required="false" /> <!-- DUPLICADO -->

Note that android.hardware.camera is also duplicated:

<uses-feature android:name="android.hardware.camera" android:required="true" /> <!-- DUPLICADO -->
<uses-permission android:name="android.permission.NFC" />
<uses-feature android:name="android.hardware.nfc" android:required="false" />
<uses-permission android:name="android.permission.CAMERA" android:required="false" />
<uses-feature android:name="android.hardware.camera" android:required="false" /> <!-- DUPLICADO -->

I.e. each permission is one way and duplicated, fix this and the app will compile, Cordova being the problem is probably in your config.xml

 1
Author: Guilherme Nascimento, 2019-10-31 03:07:45

This plugin probably does not support cordova version 9.0.0.

Try using PhoneGap Plugin barcodescanner

ionic cordova plugin add phonegap-plugin-barcodescanner
npm install @ionic-native/barcode-scanner

This plugin supports QR code, I use it in an application where I do QR code and barcode readings, very simple to use.

 1
Author: Rodrigo Alves Mesquita, 2019-10-31 02:20:38