Problems with QR Code Ionic reader

Asked

Viewed 198 times

0

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.

It is giving error in the 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, everything goes back to normal and so I can build.

If this plugin has no portability to:

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 ?

2 answers

1

Probably this plugin does not support Cordova version 9.0.0.

Try to use Phonegap Plugin Barcodescanner

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

this plugin supports QR code, use it in an application where I do readings of QR code and barcodes, very simple to use.

1


Error informs that settings are 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

Behold:

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 the 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 -->

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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.