Closed MohammedSaberMohammed closed 5 years ago
Can't see your AndroidManifest.xml, please properly escape your code...
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>
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.
@MMAANNSS so the problem has gone away after removing and re-adding the platform?
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.
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?
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
@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.
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?
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?
@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.
@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.
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.
https://github.com/iParqDevelopers/cordova-plugin-flex-camera/commit/a96d219800878bbe741e65db2a121f651808e19c
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
@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.
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
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.
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.
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.
Removing and adding again android platform Worked for me
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
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.
@ctpaula :1st_place_medal: 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!
@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));
@cristianizzo From @justinhenricks, seem QR Scanner and Barcode Scanner cannot be installed at the same time, here the related issue https://github.com/phonegap/phonegap-plugin-barcodescanner/issues/510
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.
This thread has been automatically locked.
hello everyone i have a problem which is the following when i run --> ionic run android
and this is AndroidManifest.xml