Skip to content
This repository has been archived by the owner on Aug 11, 2020. It is now read-only.

duplicated with element declared at AndroidManifest.xml #418

Closed
MohammedSaberMohammed opened this issue Feb 25, 2017 · 27 comments
Closed

duplicated with element declared at AndroidManifest.xml #418

MohammedSaberMohammed opened this issue Feb 25, 2017 · 27 comments

Comments

@MohammedSaberMohammed
Copy link

MohammedSaberMohammed commented Feb 25, 2017

hello everyone i have a problem which is the following when i run
--> ionic run android

:processDebugManifest
/home/mmask/Desktop/Ionic2_Apps/Check-in/platforms/android/AndroidManifest.xml:16:9-104 Error:
	Element meta-data#com.facebook.sdk.ApplicationId at AndroidManifest.xml:16:9-104 duplicated with element declared at AndroidManifest.xml:12:9-102
/home/mmask/Desktop/Ionic2_Apps/Check-in/platforms/android/AndroidManifest.xml Error:
	Validation failed, exiting



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


:processDebugManifest FAILED


FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':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.



BUILD FAILED



Total time: 36.179 secs

Error: /home/mmask/Desktop/Ionic2_Apps/Check-in/platforms/android/gradlew: Command failed with exit code 1 Error output:
/home/mmask/Desktop/Ionic2_Apps/Check-in/platforms/android/AndroidManifest.xml:16:9-104 Error:
	Element meta-data#com.facebook.sdk.ApplicationId at AndroidManifest.xml:16:9-104 duplicated with element declared at AndroidManifest.xml:12:9-102
/home/mmask/Desktop/Ionic2_Apps/Check-in/platforms/android/AndroidManifest.xml Error:
	Validation failed, exiting

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':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.


and this is AndroidManifest.xml

<?xml version='1.0' encoding='utf-8'?>
<manifest android:hardwareAccelerated="true" android:versionCode="1" android:versionName="0.0.1" package="com.ionicframework.tutorial526588" 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/icon" android:label="@string/app_name" android:supportsRtl="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>
        <meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/fb_app_id" />
        <meta-data android:name="com.facebook.sdk.ApplicationName" android:value="@string/fb_app_name" />
        <activity android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation" android:label="@string/fb_app_name" android:name="com.facebook.FacebookActivity" android:theme="@android:style/Theme.Translucent.NoTitleBar" />
        <meta-data android:name="com.facebook.accountkit.ApplicationName" android:value="@string/fbak_app_name" />
        <meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/fbak_app_id" />
        <meta-data android:name="com.facebook.accountkit.ClientToken" android:value="@string/fbak_app_ak_token" />
        <meta-data android:name="com.facebook.accountkit.FacebookAppEventsEnabled" android:value="false" />
    </application>
    <uses-sdk android:minSdkVersion="16" android:targetSdkVersion="25" />
</manifest>
@wildabeast
Copy link
Collaborator

Can't see your AndroidManifest.xml, please properly escape your code...

@jbankester
Copy link

I just ran into the same issue building after updating from v6.0.1 to v6.0.6.

:processReleaseManifest
C:\development\Mobile\platforms\android\AndroidManifest.xml:13:9-18:20 Error:
Element activity#com.google.zxing.client.android.CaptureActivity at AndroidManifest.xml:13:9-18:20 duplicated with element declared at AndroidManifest.xml:11:9-311

C:\development\Mobile\platforms\android\AndroidManifest.xml Error:
Validation failed, exiting

<?xml version='1.0' encoding='utf-8'?>
<manifest android:hardwareAccelerated="true" android:versionCode="10000" android:versionName="1.0.0" package="com.example.example" 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" />
    <application android:hardwareAccelerated="true" android:icon="@drawable/icon" android:label="@string/app_name" android:supportsRtl="true">
        <activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale" android:label="@string/activity_name" android:launchMode="singleTop" android:name="MainActivity" android:screenOrientation="landscape" 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" />
        <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">
            <intent-filter>
                <action android:name="com.google.zxing.client.android.SCAN" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>
    </application>
    <uses-sdk android:minSdkVersion="14" android:targetSdkVersion="23" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.READ_CONTACTS" />
    <uses-permission android:name="android.permission.WRITE_CONTACTS" />
    <uses-permission android:name="android.permission.GET_ACCOUNTS" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.RECORD_AUDIO" />
    <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
    <uses-permission android:name="android.permission.RECORD_VIDEO" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.CAMERA" />
    <uses-permission android:name="android.permission.FLASHLIGHT" />
    <uses-feature android:name="android.hardware.camera" android:required="true" />
</manifest>

@jbankester
Copy link

I found that after removing the plugin

phonegap plugin rm phonegap-plugin-barcodescanner

The following element remained in AndroidManifest.xml and would be added again on each build attempt.

<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">
            <intent-filter>
                <action android:name="com.google.zxing.client.android.SCAN" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>

I deleted the top level AndroidManifest.xml as well as the same file from

...\platforms\android\build\intermediates\manifests\full\release

and

...\platforms\android\build\intermediates\manifests\full\debug

I also deleted the android.json file from

...\platforms\android

I was then able to install the latest version of the plugin and build successfully.

@macdonst
Copy link
Member

macdonst commented Apr 6, 2017

@mmaannss so the problem has gone away after removing and re-adding the platform?

@jbankester
Copy link

Yeah, I initially tried just removing the extra element from AndroidManifest.xml but it gets put back in there if you don't get rid of it everywhere.

@thomasblom
Copy link

I still have this problem. The steps of jbankester to delete the manifest and install the plugin again and build for Android did not work. Does anyone else have a solution?

@giscafer
Copy link

Error: cmd: Command failed with exit code 1 Error output: F:\workspace\app-jzt\platforms\android\AndroidManifest.xml:131:5-65 Error: Element uses-permission#android.permission.CAMERA at AndroidManifest.xml:131:5-65 duplicated with element declared at AndroidManifest.xml:130:5-90 F:\workspace\app-jzt\platforms\android\AndroidManifest.xml:132:5-60 Error: Element uses-feature#android.hardware.camera at AndroidManifest.xml:132:5-60 duplicated with element declared at AndroidManifest.xml:128:5-85 F:\workspace\app-jzt\platforms\android\AndroidManifest.xml Error: Validation failed, exiting

@teckyin
Copy link

teckyin commented Jul 31, 2017

@mmaannss Hi, I'm having the same issue with "duplicated element declared at AndroidManifest.xml" after I've installed this barcode scanner. But for my case, there's multiple permission request on Camera and the cause of this issue is having cordova-plugin-qrscanner and phonegap-plugin-barcodescanner installed and both of the plugins is requesting the same permission. After I've removed the cordova-plugin-qrscanner everything went smooth.

@jaufgang
Copy link

jaufgang commented Aug 18, 2017

Does this mean it is not possible to have multiple plugins that use the camera used by a cordova app, even if the app does not use both plugins at the same time? Simply because they both need to ask for the same permission?

@atlesp
Copy link

atlesp commented Sep 21, 2017

I have the same issue and it seems to be caused of that I use two plugins that both uses the feature camera, but one also requires it.

    <uses-feature android:name="android.hardware.camera" />
    <uses-feature android:name="android.hardware.camera" android:required="true" />

So is the issue that it does not reconize that the use feature is there already since it uses the required =true flag?

@derrohrbach
Copy link

@atlesp I got exactly the same problem. Cordova is also generating those two lines in my app and i can not get it to build anymore. Did you already find a solution other than removing one of the plugins? Removing a plugin is not an option for me.

@atlesp
Copy link

atlesp commented Sep 29, 2017

@derrohrbach I did not find a solution. Since my app is only targeting IOS, this wa not a blocker for me.

I guess this is a bug in cordova, and not this plugin. A possible hack solution could be to clone this repo and remove the "android:required="true"" from this plugin (see https://github.com/phonegap/phonegap-plugin-barcodescanner/blob/master/plugin.xml) and then use the git clone repo assoruce. But I am not sure if it will work.

@davidquon
Copy link

Not a great or long term solution but you can fork one of the projects and changes android:required="" to match the other. I did it here for my use case and it seems to work okay. I'd ❤️ to know the status of a fix in Cordova though.
iParqDevelopers/cordova-plugin-flex-camera@a96d219

@wildabeast
Copy link
Collaborator

Seems like more an issue with cordova rather than this plugin. If someone has some quick reproduction steps can they share? Maybe something like:

phonegap create scanner
cd scanner
phonegap plugin add phonegap-plugin-barcodescanner
phonegap plugin add some-other-plugin
phonegap plugin remove ...
...
computer explodes

I (or that person) can then create an issue in the cordova jira

@derrohrbach
Copy link

@wildabeast First off: Thx for your patience

The conflict in my App is between phonegap-plugin-barcodescanner and cordova-plugin-scanbot-sdk.
You just have to add those plugins and try to build the android app, to reproduce this issue.
Alternatively you could also try cordova-plugin-qrscanner instead of the scanbot-sdk.

@wildabeast
Copy link
Collaborator

What phonegap version are you running? This compiled successfully for me for me:

phonegap -version
6.4.6
phonegap create scannertest --template blank
phonegap plugin add phonegap-plugin-barcodescanner
phonegap plugin add cordova-plugin-qrscanner # scanbot-sdk also worked
phonegap platform add android
phonegap build android

@derrohrbach
Copy link

derrohrbach commented Oct 12, 2017

I am running cordova in version 7.0.1.

If I run exactly those commands but using cordova instead of phonegap, then i get the following error message while building:

Error: cmd: Command failed with exit code 1 Error output:
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
C:\Users\marvi\Desktop\Projekte\scannertest\platforms\android\AndroidManifest.xml:19:5-65 Error:
        Element uses-permission#android.permission.CAMERA at AndroidManifest.xml:19:5-65 duplicated with element declared at AndroidManifest.xml:16:5-90
C:\Users\marvi\Desktop\Projekte\scannertest\platforms\android\AndroidManifest.xml:21:5-84 Error:
        Element uses-feature#android.hardware.camera at AndroidManifest.xml:21:5-84 duplicated with element declared at AndroidManifest.xml:17:5-85
C:\Users\marvi\Desktop\Projekte\scannertest\platforms\android\AndroidManifest.xml Error:
        Validation failed, exiting

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':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.

@wildabeast
Copy link
Collaborator

Thanks, managed to reproduce with 7.0.1. It looks like this problem has been reported a couple of times in one form or the other in the Cordova Jira, with no firm solution. So I guess we're in a "wait / hope it gets fixed" status.

A temporary solution would be forking one of the plugins and removing the problematic permissions/features, and let them be injected by the other plugin, or creating a hook which fixes the manifest for you before building.

@sagarpdesai
Copy link

After scratching my head over this for 2 days, I finally switched to this plugin and things have worked well since then.
cordova plugin add phonegap-plugin-barcodescanner
Details:
https://www.sitepoint.com/scanning-qr-code-cordova/
Note: cordova-plugin-barcodescanner kept giving errors in Android, but phonegap-plugin-barcodescanner worked.

@omid-dashing
Copy link

Removing and adding again android platform
Worked for me

@caiovncius
Copy link

caiovncius commented Jan 11, 2018

I had the sane issue with cordova-plugin-camera and phonegap-plugin-barcodescanner. My fix:

ionic cordova platform rm android 
ionic cordova platform rm ios  
ionic cordova plugin rm phonegap-plugin-barcodescanner
rm -r plugins
rm -r node_modules
rm package-lock.json

Next remove the phonegap-plugin-barcodescanner of the package.json. Run:

npm install
ionic cordova platform add android

Next do a new build:

ionic cordova run android

Next add the plugin again:

ionic cordova plugin add phonegap-plugin-barcodescanner

@ctpaula
Copy link

ctpaula commented Jan 30, 2018

I had to remove inside ..\plugins\phonegap-plugin-barcodescanner\plugin.xml the

<uses-feature android:name="android.hardware.camera">

then removed and added again android platform.
Worked very fine for me.

@afficionaddo
Copy link

@ctpaula 🥇
You are a saviour!

No need to fork the barcode-scanner repostiory. Just follow ctpaula's steps:

-Comment the line of 'uses-feature' in ...\plugins\phonegap-plugin-barcodescanner\plugin.xml
-rm platform android
-add platform android
-ionic cordova run android.

Works like a charm!

@cristianizzo
Copy link

@afficionaddo it's not working for me, it give me the following issue

/platforms/android/src/com/phonegap/plugins/barcodescanner/BarcodeScanner.java:179: error: cannot find symbol intentScan.putExtra(Intents.Scan.SHOW_FLIP_CAMERA_BUTTON, obj.optBoolean(SHOW_FLIP_CAMERA_BUTTON, false));

@dodongphure
Copy link

@cristianizzo From @justinhenricks, seem QR Scanner and Barcode Scanner cannot be installed at the same time, here the related issue #510

@stale
Copy link

stale bot commented Jun 24, 2018

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Jun 24, 2018
@stale stale bot closed this as completed Jul 1, 2018
@lock
Copy link

lock bot commented Jul 31, 2018

This thread has been automatically locked.

@lock lock bot locked as resolved and limited conversation to collaborators Jul 31, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

No branches or pull requests