0

Basically i am using QR Code Scanner using this command npm install @ionic-native/qr-scanner ionic cordova plugin add cordova-plugin-qrscanner

and after using this plug in when i go and build then getting this error and in menifest file its reproducing the error like this Menifest file before ionic cordova build android looks like

<?xml version='1.0' encoding='utf-8'?>
<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:networkSecurityConfig="@xml/network_security_config" android:supportsRtl="true" android:usesCleartextTraffic="true">
        <activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale" 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-sdk android:minSdkVersion="19" android:targetSdkVersion="28" />
    <uses-permission android:name="android.permission.FLASHLIGHT" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
</manifest>

and after running build command it is something like this

<?xml version='1.0' encoding='utf-8'?>
<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:networkSecurityConfig="@xml/network_security_config" android:supportsRtl="true" android:usesCleartextTraffic="true">
        <activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale" 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-sdk android:minSdkVersion="19" android:targetSdkVersion="28" />
    <uses-permission android:name="android.permission.FLASHLIGHT" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
     <uses-permission android:name="android.permission.CAMERA" />
    <uses-feature android:name="android.hardware.camera" android:required="true" />
    <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>

and the error is something like this

BUILD FAILED in 4s
22 actionable tasks: 1 executed, 21 up-to-date
D:\New CouponCode\platforms\android\gradlew: Command failed with exit code 1 Error output:
D:\New CouponCode\platforms\android\app\src\main\AndroidManifest.xml:20:5-90 Error:
        Element uses-permission#android.permission.CAMERA at AndroidManifest.xml:20:5-90 duplicated with element declared at AndroidManifest.xml:18:5-65
D:\New CouponCode\platforms\android\app\src\main\AndroidManifest.xml:21:5-85 Error:
        Element uses-feature#android.hardware.camera at AndroidManifest.xml:21:5-85 duplicated with element declared at AndroidManifest.xml:19:5-84
D:\New CouponCode\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
  • Please import your android code to android studio and try [https://stackoverflow.com/a/45474441/11259240](https://stackoverflow.com/a/45474441/11259240) – hi hi Jan 31 '20 at 03:44

1 Answers1

0

If you read the error codes, you can see that there are duplicated elements in AndroidManifest.xml

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

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

Please choose only one uses-permission and uses-feature for the CAMERA plugin.

<uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardware.camera" android:required="true" />
<uses-permission android:name="android.permission.CAMERA" android:required="false" />
<uses-feature android:name="android.hardware.camera" android:required="false" />
Community
  • 1
  • 1
Tomas Vancoillie
  • 3,463
  • 2
  • 29
  • 45
  • this was not the case basically what i am trying to say is , i have already removed this four lines before build and after running build command its atuomatically adding these four line and i have also tried the other scenario in which i have just wrote one camera permission line again the result is as always. – Abdul Wahab Jan 31 '20 at 09:54