hypery2k / cordova-barcodescanner-plugin

barcode scanner plugin for PhoneGap
51 stars 39 forks source link

Build doesn't work after installing #27

Closed tribalboy3000 closed 6 years ago

tribalboy3000 commented 6 years ago

Here is my process:

install: cordova plugin add cordova-plugin-barcodescanner

add to config.xml:

 <config-file mode="merge" parent="/*" target="AndroidManifest.xml">
        <uses-permission android:name="android.permission.CAMERA" />
        <uses-feature android:name="android.hardware.camera" />
        <uses-feature android:name="android.hardware.camera.autofocus" />
    </config-file>

run: cordova build android

Error: Error: /Applications/MAMP/htdocs/hhFramework/app/platforms/android/gradlew: Command failed with exit code 1 Error output: [Fatal Error] :12:352: The value of the attribute "prefix="xmlns",localpart="android",rawname="xmlns:android"" is invalid. Prefixed namespace bindings may not be empty.

FAILURE: Build failed with an exception.

derekcdaley commented 6 years ago

I'm experiencing the same issue.

Why are the permissions being set like this? `

`

The empty xmlns:android namespace is causing the build to fail for me.

tribalboy3000 commented 6 years ago

Hello??? Is this thing on???

semihaltintas commented 6 years ago

Same issue, does anyone solve problem?

semihaltintas commented 6 years ago

BUILD FAILED

Total time: 1.301 secs Error: /project/gradlew: Command failed with exit code 1 Error output: [Fatal Error] :13:352: The value of the attribute "prefix="xmlns",localpart="android",rawname="xmlns:android"" is invalid. Prefixed namespace bindings may not be empty.

FAILURE: Build failed with an exception.

rebrandsoftware commented 6 years ago

I have the same issue trying to use PhoneGap Build cli-7.0.1, which uses Cordova 6.2.3 for Android.

First, I tried it as stated in the plugin docs:

`

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

`

That didn't work so I tried it the way the Cordova docs specify:

`

        <uses-feature android:name="android.hardware.camera" />
        <uses-feature android:name="android.hardware.camera.autofocus" />
    </config-file>`

That didn't work either. I'm adding the Android namespace to my config like this:

xmlns:android="http://schemas.android.com/apk/res/android"

But that doesn't make any difference.

I looked at past versions of my code and it used to compile without any config additions. I just used the Cordova-android-permissons plugin to ask for camera permission before calling the plugin. Now, that doesn't work because the build fails.

Any suggestions?

rebrandsoftware commented 6 years ago

If I roll back to 0.7.1 on NPM it compiles properly. Not sure what changed between versions.

Edit:

However, I still get Scanning Failed: write settings: false

I will play around with the config file to see if I can get it working.

rebrandsoftware commented 6 years ago

I have it working using PhoneGap Build for version 0.7.0 if anyone wants to roll back while we wait, my config contains:

<widget xmlns="http://www.w3.org/ns/widgets" xmlns:gap="http://phonegap.com/ns/1.0" xmlns:android="http://schemas.android.com/apk/res/android" id="com.rebrandsoftware.appname" versionCode="1" version="1.0.0">

<preference name="phonegap-version" value="cli-7.0.1" /> <preference name='pgb-builder-version' value='2' />

<plugin name="cordova-plugin-barcodescanner" spec="0.7.0" source="npm" /> <plugin name="cordova-plugin-android-permissions" spec="1.0.0" source="npm" />

<platform name="android"> <config-file target="AndroidManifest.xml" parent="/*" mode="merge"> <uses-permission android:name="android.permission.CAMERA" /> <uses-feature android:name="android.hardware.camera" /> <uses-feature android:name="android.hardware.camera.autofocus" /> </config-file> </platform> `

And to check permissions just in case I'm doing this:

var scan = function() {

 cordova.plugins.barcodeScanner.scan(
     function(result) {
         // alert("We got a barcode\n" +
         // "Result: " + result.text + "\n" +
         // "Format: " + result.format + "\n" +
         // "Cancelled: " + result.cancelled);

     },
     function(error) {
         alert("Scanning failed: " + error);
     }
 );

};

if (Device.platform === "Android") { var permissions = cordova.plugins.permissions; permissions.hasPermission(permissions.CAMERA, checkPermissionCallback, null);

 function checkPermissionCallback(status) {
     if (!status.hasPermission) {
         var errorCallback = function() {
             console.warn('Camera permission is not turned on');
         };

         permissions.requestPermission(
             permissions.CAMERA,
             function(status) {
                 if (!status.hasPermission) {
                     errorCallback();
                 } else {
                     scan();
                 }
             },
             errorCallback);
     } else {
         scan();
     }
 }

} else { scan(); }

hypery2k commented 6 years ago

try again with 0.7.3

ingo-lorenz commented 6 years ago

Hi,

thank you for the update, but is still not working. The xml error is already displayed at build the app.

[Fatal Error] :12:139: Wert des Attributs "prefix="xmlns",localpart="android",rawname="xmlns:android"" ist ungültig. Namespace Bindings mit Präfix dürfen nicht leer sein.

Thank you.

peterhecker65 commented 6 years ago

Hello Pompingo,

this worked for me:

cordova plugin remove cordova-plugin-barcodescanner cordova plugin add cordova-plugin-barcodescanner@0.7.1

Add the 'xmlns:android="http://schemas.android.com/apk/res/android"' in config.xml:

<config-file mode="merge" parent="/*" target="AndroidManifest.xml">
    <uses-permission android:name="android.permission.CAMERA" xmlns:android="http://schemas.android.com/apk/res/android" />
    <uses-feature android:name="android.hardware.camera" xmlns:android="http://schemas.android.com/apk/res/android" />
    <uses-feature android:name="android.hardware.camera.autofocus" xmlns:android="http://schemas.android.com/apk/res/android" />
</config-file>

Maybe this helps ;-)

cscumming-dwss commented 6 years ago

peterhecker65, Followed the suggestion, but now get the following error: :processDebugManifestC:\workspaces\ion-scanner\platforms\android\AndroidManifest.xml:36:5-85 Error: Element uses-feature#android.hardware.camera at AndroidManifest.xml:36:5-85 duplicated with element declared at AndroidManifest.xml:33:5-60

I tried editing AndroidManifest but that is ineffective since it is overwritten.

So I am wondering if some version of something is not correct.

What versions are are others using to get this to build? This is what I have

Installed platforms: android 6.2.3 browser 5.0.0 ios 4.5.1

Here are the plugins - I don't think any of these should be adding the duplicate.

cordova plugin list cordova-plugin-barcodescanner 0.7.1 "BarcodeScanner" cordova-plugin-compat 1.2.0 "Compat" cordova-plugin-device 1.1.4 "Device" cordova-plugin-splashscreen 4.0.3 "Splashscreen" cordova-plugin-statusbar 2.2.4-dev "StatusBar" cordova-plugin-whitelist 1.3.2 "Whitelist" ionic-plugin-keyboard 2.2.1 "Keyboard"

Thanks.

kirillplatonov commented 6 years ago

@hypery2k after installing 0.7.3 I have the same error as before:

[Fatal Error] :35:139: The value of the attribute "prefix="xmlns",localpart="android",rawname="xmlns:android"" is invalid. Prefixed namespace bindings may not be empty.

Tried ionic remove/add plugin, ionic remove/add android. Nothing helps( Any ideas how to fix it?

kirillplatonov commented 6 years ago

@cscumming-dwss I found reference to this problem: https://issues.apache.org/jira/browse/CB-12255?jql=text%20~%20%22android%20manifest%20duplicates%22 As a workaround for now - fork cordova-barcodescanner-plugin and remove permissions requirement. It's described here: https://github.com/phonegap/phonegap-plugin-barcodescanner/issues/418#issuecomment-338076932

kirillplatonov commented 6 years ago

Steps to fix this problem which worked for me:

  1. In config.xml add xmlns:android="http://schemas.android.com/apk/res/android" to widget
  2. Run
    cordova plugin remove cordova-plugin-barcodescanner
    cordova plugin add cordova-plugin-barcodescanner@0.7.0
  3. In plugins/cordova-plugin-barcodescanner/plugin.xml comment or remove line
    <uses-feature android:name="android.hardware.camera" android:required="false"/>
  4. Run
    cordova platform remove android
    cordova platform add android
raprincis commented 6 years ago

Hello, Fixed it by adding android namespace in config file

`

    <uses-feature android:name="android.hardware.camera" />
    <uses-feature android:name="android.hardware.camera.autofocus" />
</config-file>`
ranismk commented 6 years ago

Trick by @kirillplatonov worked perfectly for me...thanks mate!

satsathish commented 6 years ago

This is how I've solved it.

  1. Open plugins/cordova-plugin-barcode-scanner/plugin.xml and delete all records xmlns:android=""

  2. Open platforms/android/android.json and delete all xmlns:android=\"\"

  3. Do the same in platforms/android/AndroidManifest.xml

xmlns:android can't be empty like error tells us:

The value of the attribute "prefix="xmlns",localpart="android",rawname="xmlns:android"" is invalid. Prefixed namespace bindings may not be empty.

rafwell commented 6 years ago

Why this bug remains until today? This is sad. Thanks @kirillplatonov

hypery2k commented 6 years ago

a little nicer comment would be great. Fixed in 0.7.4

Keep in mind: Free Open Source software does not mean free in terms of free beer.

BTW: Will discontinue this plugin

rafwell commented 6 years ago

Sorry, I did not mean to offend you. You did a great job, I thank you so much for that. But sometimes it seems that repositories are forgotten and this is sad for the whole community.

Again, sorry if I was rude or maybe google translator misunderstood me.

hypery2k commented 6 years ago

sure, but keep in mind most people do this in their spare time. So maybe they got other stuff to do.