cordova 的条形码扫描器插件导致 config.xml 错误

cordova's barcode scanner plugin causes config.xml error

我正在尝试使用 cordova.plugin.barcodescanner 来处理我的应用程序。 该插件将这些行添加到我的 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>

当我尝试构建 apk(调试)时,出现格式错误 config.xml 错误。

然后我将其添加到我的小部件标签中:

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

导致正确构建应用程序,但我的 http.get(ajax) 中断并停止工作。

这是我的全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="TEST@gmail.com" 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>  

这是我的日志:

构建日期:2018-10-31 09:43:49 +0000

插件输出

正在通过 npm 获取插件 "cordova-plugin-whitelist@1" 在 android

的“1.3.3”安装 "cordova-plugin-whitelist"

此插件仅适用于大于 4.0 的 cordova-android 版本。如果您有以前的平台版本,您 不需要 这个插件,因为白名单将内置。 通过 npm 获取插件 "cordova-plugin-device@1.1.3" 在 android 的“1.1.3”安装 "cordova-plugin-device" 通过 npm 获取插件 "cordova-plugin-geolocation@2.4.0" 在 android 的“2.4.0”安装 "cordova-plugin-geolocation" 通过 npm 获取插件 "cordova-plugin-compat@^1.0.0" 在 android 的“1.2.0”安装 "cordova-plugin-compat" android 上已安装插件 "cordova-plugin-compat"。使其成为顶级。 通过 npm 获取插件 "cordova-plugin-splashscreen@4.0.1" 在 android 的“4.0.1”安装 "cordova-plugin-splashscreen" 警告:将 compileSdkVersion 从 android-25(默认)覆盖到 android-26

警告:这是不受支持的,请考虑更新您的 phonegap 版本

项目属性

此文件由 Android 工具自动生成。 不要修改此文件 -- 您的更改将被删除!

必须在版本控制系统中检查此文件。

自定义 Ant 构建系统使用的属性编辑 "ant.properties",并覆盖值以使脚本适应您的 项目结构。

要使 ProGuard 能够缩小和混淆您的代码,请取消注释(可用属性:sdk.dir、user.home): proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt 项目目标。 目标=android-26

android.library.reference.1=CordovaLib

编译输出

子项目路径:CordovaLib 运行 命令:/project/gradlew cdvBuildDebug -b /project/build.gradle -Dorg.gradle.daemon=true -Dorg.gradle.jvmargs=-Xmx2048m -Pandroid.useDeprecatedNdk=真的 Task.leftShift(Closure) 方法已被弃用,并计划在 Gradle 5.0 中删除。请改用 Task.doLast(Action)。 在 build_dwomais0s9mkq91rc7xy5fcb5.run(/project/build.gradle:137) JavaCompile.setDependencyCacheDir() 方法已被弃用,并计划在 Gradle 4.0 中删除。 增量 java 编译是一项孵化功能。 TaskInputs.source(Object) 方法已被弃用,并计划在 Gradle 4.0 中删除。请改用 TaskInputs.file(Object).skipWhenEmpty() 。 ProjectDependency.getProjectConfiguration() 方法已被弃用,并计划在 Gradle 4.0 中删除。 ModuleDependency.getConfiguration() 已被弃用,并计划在 Gradle 4.0 中删除。使用 ModuleDependency.getTargetConfiguration() 代替。 :preBuild 最新 :preDebugBuild 最新 :检查调试清单 :CordovaLib:preBuild 最新 :CordovaLib:preDebugBuild 最新版本 :CordovaLib:检查调试清单 :CordovaLib:prepareDebugDependencies :CordovaLib:compileDebugAidl :CordovaLib:compileDebugNdk 最新 :CordovaLib:compileLint :CordovaLib:copyDebugLint 最新 :CordovaLib:mergeDebugShaders :CordovaLib:compileDebugShaders :CordovaLib:generateDebugAssets :CordovaLib:mergeDebugAssets :CordovaLib:mergeDebugProguardFiles :CordovaLib:packageDebugRenderscript 最新 :CordovaLib:compileDebugRenderscript :CordovaLib:generateDebugResValues :CordovaLib:generateDebugResources :CordovaLib:packageDebugResources :CordovaLib:processDebugManifest :CordovaLib:generateDebugBuildConfig :CordovaLib:processDebugResources :CordovaLib:generateDebugSources :CordovaLib:incrementalDebugJavaCompilationSafeguard :CordovaLib:compileDebugJavaWithJavac :CordovaLib:compileDebugJavaWithJavac - 不是增量的(例如输出已更改,之前没有执行等)。 注意:某些输入文件使用或覆盖已弃用的 API。 注意:使用 -Xlint:deprecation 重新编译以获取详细信息。 :CordovaLib:processDebugJavaRes 最新 :CordovaLib:transformResourcesWithMergeJavaResForDebug :CordovaLib:transformClassesAndResourcesWithSyncLibJarsForDebug :CordovaLib:mergeDebugJniLibFolders :CordovaLib:transformNative_libsWithMergeJniLibsForDebug :CordovaLib:transformNative_libsWithSyncJniLibsForDebug :CordovaLib:捆绑调试 :prepareProjectCordovaLibUnspecifiedDebugLibrary :prepareDebugDependencies :compileDebugAidl :compileDebugRenderscript :generateDebugBuildConfig :generateDebugResValues :generateDebugResources :mergeDebugResources :processDebugManifest :processDebugResources :generateDebugSources :incrementalDebugJavaCompilationSafeguard :compileDebugJavaWithJavac :compileDebugJavaWithJavac - 不是增量的(例如,输出已更改,之前没有执行等)。 注意:某些输入文件使用或覆盖已弃用的 API。 注意:使用 -Xlint:deprecation 重新编译以获取详细信息。 :compileDebugNdk 最新 :compileDebugSources :mergeDebugShaders :compileDebugShaders :generateDebugAssets :mergeDebugAssets :transformClassesWithDexForDebug :mergeDebugJniLib文件夹 :transformNative_libsWithMergeJniLibsForDebug :processDebugJavaRes 最新 :transformResourcesWithMergeJavaResForDebug :validateSigningDebug :包调试 :assemble调试 :cdvBuildDebug

构建成功 总时间:2.007 秒 命令已完成,错误代码为 0:/project/gradlew cdvBuildDebug,-b,/project/build.gradle,-Dorg.gradle.daemon=true,-Dorg.gradle.jvmargs=-Xmx2048m,-Pandroid.useDeprecatedNdk=真 构建了以下 apk: /project/build/outputs/apk/project-debug.apk

您必须将这些行添加到 <platform name="android"> 标签中

而且我认为您必须对这些行执行相同的操作 (<platform name="ios"> ):

<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>