【问题标题】:cordova's barcode scanner plugin causes config.xml errorcordova 的条码扫描器插件导致 config.xml 错误
【发布时间】:2018-10-30 12:54:14
【问题描述】:

我正在尝试使用 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(debug) 时,出现格式错误的 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” 在“1.3.3”为android安装“cordova-plugin-whitelist”

这个插件只适用于cordova-android 4.0以上的版本。如果你有以前的平台版本,你确实不需要这个插件,因为白名单是内置的。 通过 npm 获取插件“cordova-plugin-device@1.1.3” 在“1.1.3”为 android 安装“cordova-plugin-device” 通过 npm 获取插件“cordova-plugin-geolocation@2.4.0” 在“2.4.0”为android安装“cordova-plugin-geolocation” 通过 npm 获取插件“cordova-plugin-compat@^1.0.0” 在“1.2.0”为 android 安装“cordova-plugin-compat” 插件“cordova-plugin-compat”已安装在 android 上。使其成为顶级。 通过 npm 获取插件“cordova-plugin-splashscreen@4.0.1” 在“4.0.1”为 android 安装“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=true 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 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 最新 :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:bundleDebug :prepareProjectCordovaLibUnspecifiedDebugLibrary :prepareDebugDependencies :compileDebugAidl :compileDebugRenderscript :generateDebugBuildConfig :generateDebugResValues :generateDebugResources :mergeDebugResources :processDebugManifest :processDebugResources :generateDebugSources :incrementalDebugJavaCompilationSafeguard :compileDebugJavaWithJavac :compileDebugJavaWithJavac - 不是增量的(例如输出已更改,之前没有执行等)。 注意:某些输入文件使用或覆盖已弃用的 API。 注意:使用 -Xlint:deprecation 重新编译以获取详细信息。 :compileDebugNdk 最新 :compileDebugSources :mergeDebugShaders :compileDebugShaders :generateDebugAssets :mergeDebugAssets :transformClassesWithDexForDebug :mergeDebugJniLibFolders :transformNative_libsWithMergeJniLibsForDebug :processDebugJavaRes 最新 :transformResourcesWithMergeJavaResForDebug :validateSigningDebug :packageDebug :assembleDebug :cdvBuildDebug

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

【问题讨论】:

    标签: cordova cordova-plugins phonegap-plugins phonegap-build phonegap


    【解决方案1】:

    您必须将这些行添加到&lt;platform name="android"&gt; 标记中

    我认为你必须为这些行做同样的事情(<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>
    

    【讨论】:

    • 感谢您的回答。您的解决方案可以成功构建 apk,而且 ajax 也可以正常工作。但是现在条形码扫描仪不再工作了。当然,当我尝试使用 phonegap 桌面应用程序时,整个应用程序都可以完美运行。
    • 你有日志吗?
    • 我已经更新了我的原始问题并插入了日志,它似乎没有安装条形码扫描仪插件
    • 谢谢.. 您的解决方案有效,而且,正如您指出的日志,插件未正确安装,因此重新安装固定插件问题,其中 标签解决了其他错误。非常感谢您的支持和耐心。
    猜你喜欢
    • 1970-01-01
    • 2014-09-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-07-12
    • 2013-08-11
    • 1970-01-01
    • 2016-05-08
    相关资源
    最近更新 更多