Search code examples
cordovacordova-pluginsphonegap-pluginsphonegap-buildphonegap

cordova's barcode scanner plugin causes config.xml error


I am trying to use cordova.plugin.barcodescanner to work with my app. the plugin adds these lines to my 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>

when I try to build apk(debug), I get malformed config.xml error.

Then I add this to my widget tag:

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

resulting in building the app properly, but my http.get(ajax) breaks and stops working.

Here's my full config.xml

<?xml version='1.0' encoding='utf-8'?>  
<widget android-versionCode="24" defaultlocale="en-US" id="com.fynsis.fyncrmqrapp" version="1.0.0" xmlns:android="http://schemas.android.com/apk/res/android" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0" xmlns:vs="http://schemas.microsoft.com/appx/2014/htmlapps">  
    <name><MY APP NAME></name>  
    <description><MY DESC></description>  
    <author email="[email protected]" href=""><MY NAME></author>  
    <content src="index.html" />  
    <access origin="*" />  
    <vs:features />  
    <preference name="SplashScreen" value="screen" />  
    <preference name="AutoHideSplashScreen" value="true" />  
    <preference name="ShowSplashScreenSpinner" value="false" />  
    <preference name="SplashScreenDelay" value="4000" />  
    <preference name="windows-target-version" value="8.1" />  
    <preference name="loadUrlTimeoutValue" value="700000" />  
    <plugin name="cordova-plugin-whitelist" version="1" />  
    <allow-intent href="http://*/*" />  
    <allow-intent href="https://*/*" />  
    <allow-intent href="tel:*" />  
    <allow-intent href="sms:*" />  
    <allow-intent href="mailto:*" />  
    <allow-intent href="geo:*" />  
    <platform name="android">  
        <allow-intent href="market:*" />  
    </platform>  
    <platform name="ios">  
        <allow-intent href="itms:*" />  
        <allow-intent href="itms-apps:*" />  
    </platform>  
    <platform name="android">  
        <icon density="ldpi" src="res/icons/android/icon-36-ldpi.png" />  
        <icon density="mdpi" src="res/icons/android/icon-48-mdpi.png" />  
        <icon density="hdpi" src="res/icons/android/icon-72-hdpi.png" />  
        <icon density="xhdpi" src="res/icons/android/icon-96-xhdpi.png" />  
    </platform>  
    <platform name="ios">  
        <icon height="180" src="res/icons/ios/icon-60-3x.png" width="180" />  
        <icon height="60" src="res/icons/ios/icon-60.png" width="60" />  
        <icon height="120" src="res/icons/ios/icon-60-2x.png" width="120" />  
        <icon height="76" src="res/icons/ios/icon-76.png" width="76" />  
        <icon height="152" src="res/icons/ios/icon-76-2x.png" width="152" />  
        <icon height="40" src="res/icons/ios/icon-40.png" width="40" />  
        <icon height="80" src="res/icons/ios/icon-40-2x.png" width="80" />  
        <icon height="57" src="res/icons/ios/icon-57.png" width="57" />  
        <icon height="114" src="res/icons/ios/icon-57-2x.png" width="114" />  
        <icon height="72" src="res/icons/ios/icon-72.png" width="72" />  
        <icon height="144" src="res/icons/ios/icon-72-2x.png" width="144" />  
        <icon height="29" src="res/icons/ios/icon-small.png" width="29" />  
        <icon height="58" src="res/icons/ios/icon-small-2x.png" width="58" />  
        <icon height="50" src="res/icons/ios/icon-50.png" width="50" />  
        <icon height="100" src="res/icons/ios/icon-50-2x.png" width="100" />  
    </platform>  
    <platform name="windows">  
        <icon height="150" src="res/icons/windows/Square150x150Logo.scale-100.png" width="150" />  
        <icon height="360" src="res/icons/windows/Square150x150Logo.scale-240.png" width="360" />  
        <icon height="30" src="res/icons/windows/Square30x30Logo.scale-100.png" width="30" />  
        <icon height="310" src="res/icons/windows/Square310x310Logo.scale-100.png" width="310" />  
        <icon height="44" src="res/icons/windows/Square44x44Logo.scale-100.png" width="44" />  
        <icon height="106" src="res/icons/windows/Square44x44Logo.scale-240.png" width="106" />  
        <icon height="70" src="res/icons/windows/Square70x70Logo.scale-100.png" width="70" />  
        <icon height="71" src="res/icons/windows/Square71x71Logo.scale-100.png" width="71" />  
        <icon height="170" src="res/icons/windows/Square71x71Logo.scale-240.png" width="170" />  
        <icon height="50" src="res/icons/windows/StoreLogo.scale-100.png" width="50" />  
        <icon height="120" src="res/icons/windows/StoreLogo.scale-240.png" width="120" />  
        <icon height="150" src="res/icons/windows/Wide310x150Logo.scale-100.png" width="310" />  
        <icon height="360" src="res/icons/windows/Wide310x150Logo.scale-240.png" width="744" />  
    </platform>  
    <platform name="wp8">  
        <icon height="99" src="res/icons/wp8/ApplicationIcon.png" width="99" />  
        <icon height="159" src="res/icons/wp8/Background.png" width="159" />  
    </platform>  
    <platform name="android">  
        <splash density="land-hdpi" src="res/screens/android/screen-hdpi-landscape.png" />  
        <splash density="land-ldpi" src="res/screens/android/screen-ldpi-landscape.png" />  
        <splash density="land-mdpi" src="res/screens/android/screen-mdpi-landscape.png" />  
        <splash density="land-xhdpi" src="res/screens/android/screen-xhdpi-landscape.png" />  
        <splash density="port-hdpi" src="res/screens/android/screen-hdpi-portrait.png" />  
        <splash density="port-ldpi" src="res/screens/android/screen-ldpi-portrait.png" />  
        <splash density="port-mdpi" src="res/screens/android/screen-mdpi-portrait.png" />  
        <splash density="port-xhdpi" src="res/screens/android/screen-xhdpi-portrait.png" />  
    </platform>  
    <platform name="ios">  
        <splash height="480" src="res/screens/ios/screen-iphone-portrait.png" width="320" />  
        <splash height="960" src="res/screens/ios/screen-iphone-portrait-2x.png" width="640" />  
        <splash height="1024" src="res/screens/ios/screen-ipad-portrait.png" width="768" />  
        <splash height="2048" src="res/screens/ios/screen-ipad-portrait-2x.png" width="1536" />  
        <splash height="1136" src="res/screens/ios/screen-iphone-568h-2x.png" width="640" />  
        <splash height="1334" src="res/screens/ios/screen-iphone-portrait-667h.png" width="750" />  
        <splash height="2208" src="res/screens/ios/screen-iphone-portrait-736h.png" width="1242" />  
        <splash height="1242" src="res/screens/ios/screen-iphone-landscape-736h.png" width="2208" />  
    </platform>  
    <platform name="windows">  
        <splash height="300" src="res/screens/windows/SplashScreen.scale-100.png" width="620" />  
        <splash height="1920" src="res/screens/windows/SplashScreen.scale-240.png" width="1152" />  
        <splash height="1920" src="res/screens/windows/SplashScreenPhone.scale-240.png" width="1152" />  
    </platform>  
    <platform name="wp8">  
        <splash height="1280" src="res/screens/wp8/SplashScreenImage.png" width="768" />  
    </platform>  
    <preference name="android-minSdkVersion" value="19" />  
    <preference name="android-maxSdkVersion" value="28" />  
    <preference name="android-targetSdkVersion" value="26" />  
    <preference name="Orientation" value="portrait" />  
    <plugin name="cordova-plugin-device" version="1.1.3" />  
    <plugin name="cordova-plugin-geolocation" version="2.4.0" />  
    <plugin name="cordova-plugin-compat" version="1.1.0" />  
    <plugin name="cordova-plugin-splashscreen" version="4.0.1" />  
    <edit-config file="*-Info.plist" mode="merge" target="NSLocationWhenInUseUsageDescription">  
        <string>This app features timesheet entries, i.e, user can punch in/out recording their date, time and location. work hours are calculated based on it. The location information is sent their own CRM systems for their manager's reference for reviewing timesheets.</string>  
    </edit-config>  
    <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>  
    <engine name="android" spec="~5.1.1" />  
</widget>  

Here's my log:

Build Date: 2018-10-31 09:43:49 +0000

PLUGIN OUTPUT

Fetching plugin "cordova-plugin-whitelist@1" via npm Installing "cordova-plugin-whitelist" at "1.3.3" for android

This plugin is only applicable for versions of cordova-android greater than 4.0. If you have a previous platform version, you do not need this plugin since the whitelist will be built in. Fetching plugin "[email protected]" via npm Installing "cordova-plugin-device" at "1.1.3" for android Fetching plugin "[email protected]" via npm Installing "cordova-plugin-geolocation" at "2.4.0" for android Fetching plugin "cordova-plugin-compat@^1.0.0" via npm Installing "cordova-plugin-compat" at "1.2.0" for android Plugin "cordova-plugin-compat" already installed on android. Making it top-level. Fetching plugin "[email protected]" via npm Installing "cordova-plugin-splashscreen" at "4.0.1" for android WARNING: Overriding compileSdkVersion from android-25 (default) to android-26

WARNING: This is unsupported, please consider updating your phonegap version instead

PROJECT PROPERTIES

This file is automatically generated by Android Tools. Do not modify this file -- YOUR CHANGES WILL BE ERASED!

This file must be checked in Version Control Systems.

To customize properties used by the Ant build system edit "ant.properties", and override values to adapt the script to your project structure.

To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt Project target. target=android-26

android.library.reference.1=CordovaLib

COMPILE OUTPUT

Subproject Path: CordovaLib Running command: /project/gradlew cdvBuildDebug -b /project/build.gradle -Dorg.gradle.daemon=true -Dorg.gradle.jvmargs=-Xmx2048m -Pandroid.useDeprecatedNdk=true The Task.leftShift(Closure) method has been deprecated and is scheduled to be removed in Gradle 5.0. Please use Task.doLast(Action) instead. at build_dwomais0s9mkq91rc7xy5fcb5.run(/project/build.gradle:137) The JavaCompile.setDependencyCacheDir() method has been deprecated and is scheduled to be removed in Gradle 4.0. Incremental java compilation is an incubating feature. The TaskInputs.source(Object) method has been deprecated and is scheduled to be removed in Gradle 4.0. Please use TaskInputs.file(Object).skipWhenEmpty() instead. The ProjectDependency.getProjectConfiguration() method has been deprecated and is scheduled to be removed in Gradle 4.0. ModuleDependency.getConfiguration() has been deprecated and is scheduled to be removed in Gradle 4.0. Use ModuleDependency.getTargetConfiguration() instead. :preBuild UP-TO-DATE :preDebugBuild UP-TO-DATE :checkDebugManifest :CordovaLib:preBuild UP-TO-DATE :CordovaLib:preDebugBuild UP-TO-DATE :CordovaLib:checkDebugManifest :CordovaLib:prepareDebugDependencies :CordovaLib:compileDebugAidl :CordovaLib:compileDebugNdk UP-TO-DATE :CordovaLib:compileLint :CordovaLib:copyDebugLint UP-TO-DATE :CordovaLib:mergeDebugShaders :CordovaLib:compileDebugShaders :CordovaLib:generateDebugAssets :CordovaLib:mergeDebugAssets :CordovaLib:mergeDebugProguardFiles :CordovaLib:packageDebugRenderscript UP-TO-DATE :CordovaLib:compileDebugRenderscript :CordovaLib:generateDebugResValues :CordovaLib:generateDebugResources :CordovaLib:packageDebugResources :CordovaLib:processDebugManifest :CordovaLib:generateDebugBuildConfig :CordovaLib:processDebugResources :CordovaLib:generateDebugSources :CordovaLib:incrementalDebugJavaCompilationSafeguard :CordovaLib:compileDebugJavaWithJavac :CordovaLib:compileDebugJavaWithJavac - is not incremental (e.g. outputs have changed, no previous execution, etc.). Note: Some input files use or override a deprecated API. Note: Recompile with -Xlint:deprecation for details. :CordovaLib:processDebugJavaRes UP-TO-DATE :CordovaLib:transformResourcesWithMergeJavaResForDebug :CordovaLib:transformClassesAndResourcesWithSyncLibJarsForDebug :CordovaLib:mergeDebugJniLibFolders :CordovaLib:transformNative_libsWithMergeJniLibsForDebug :CordovaLib:transformNative_libsWithSyncJniLibsForDebug :CordovaLib:bundleDebug :prepareProjectCordovaLibUnspecifiedDebugLibrary :prepareDebugDependencies :compileDebugAidl :compileDebugRenderscript :generateDebugBuildConfig :generateDebugResValues :generateDebugResources :mergeDebugResources :processDebugManifest :processDebugResources :generateDebugSources :incrementalDebugJavaCompilationSafeguard :compileDebugJavaWithJavac :compileDebugJavaWithJavac - is not incremental (e.g. outputs have changed, no previous execution, etc.). Note: Some input files use or override a deprecated API. Note: Recompile with -Xlint:deprecation for details. :compileDebugNdk UP-TO-DATE :compileDebugSources :mergeDebugShaders :compileDebugShaders :generateDebugAssets :mergeDebugAssets :transformClassesWithDexForDebug :mergeDebugJniLibFolders :transformNative_libsWithMergeJniLibsForDebug :processDebugJavaRes UP-TO-DATE :transformResourcesWithMergeJavaResForDebug :validateSigningDebug :packageDebug :assembleDebug :cdvBuildDebug

BUILD SUCCESSFUL Total time: 2.007 secs Command finished with error code 0: /project/gradlew cdvBuildDebug,-b,/project/build.gradle,-Dorg.gradle.daemon=true,-Dorg.gradle.jvmargs=-Xmx2048m,-Pandroid.useDeprecatedNdk=true Built the following apk(s): /project/build/outputs/apk/project-debug.apk


Solution

  • You have to add the lines into <platform name="android"> tag

    And i think you have to do the same (<platform name="ios"> ) for these lines :

    <edit-config file="*-Info.plist" mode="merge" target="NSLocationWhenInUseUsageDescription">  
        <string>This app features timesheet entries, i.e, user can punch in/out recording their date, time and location. work hours are calculated based on it. The location information is sent their own CRM systems for their manager's reference for reviewing timesheets.</string>  
    </edit-config>