Android - phonegap错误:解析XML时出错:未绑定的前缀

Max*_*ain 13 javascript java xml phonegap-plugins cordova

我重新启动了eclipse并将错误更改为"错误:解析XML:解除绑定错误前缀"错误

我想在我的android phonegap应用程序中使用插件.这是一个本地通知插件.我在此行的config.xml文件中收到错误:

<gap:plugin name="de.appplant.cordova.plugin.local-notification" version="0.6.2" />
Run Code Online (Sandbox Code Playgroud)

有一个关于这个问题的一个类似的问题在这里,但答案是不相关的我的问题.

这是我的config.xml文件:

<?xml version="1.0" encoding="UTF-8"?>
<widget xmlns     = "http://www.w3.org/ns/widgets"
        id        = "com.xxx.xxx"
        version   = "2.0.0">
    <name>xxx</name>

    <description>
    xxx
    </description>

    <author href="http://www.example.com" email="xxx@yahoo.com">
    xxx
    </author>

    <access origin="*"/>

    <!-- <content src="xxx" /> for external pages -->
    <content src="index.html" />

    <preference name="loglevel" value="DEBUG" />
    <!--
      <preference name="splashscreen" value="resourceName" />
      <preference name="backgroundColor" value="0xFFF" />
      <preference name="loadUrlTimeoutValue" value="20000" />
      <preference name="InAppBrowserStorageEnabled" value="true" />
      <preference name="disallowOverscroll" value="true" />
    -->

    <feature name="App">
      <param name="android-package" value="org.apache.cordova.App"/>
    </feature>
    <feature name="Geolocation">
      <param name="android-package" value="org.apache.cordova.GeoBroker"/>
    </feature>
    <feature name="Device">
      <param name="android-package" value="org.apache.cordova.Device"/>
    </feature>
    <feature name="Accelerometer">
      <param name="android-package" value="org.apache.cordova.AccelListener"/>
    </feature>
    <feature name="Compass">
      <param name="android-package" value="org.apache.cordova.CompassListener"/>
    </feature>
    <feature name="Media">
      <param name="android-package" value="org.apache.cordova.AudioHandler"/>
    </feature>
    <feature name="Camera">
      <param name="android-package" value="org.apache.cordova.CameraLauncher"/>
    </feature>
    <feature name="Contacts">
      <param name="android-package" value="org.apache.cordova.ContactManager"/>
    </feature>
    <feature name="File">
      <param name="android-package" value="org.apache.cordova.FileUtils"/>
    </feature>
    <feature name="NetworkStatus">
      <param name="android-package" value="org.apache.cordova.NetworkManager"/>
    </feature>
    <feature name="Notification">
      <param name="android-package" value="org.apache.cordova.Notification"/>
    </feature>
    <feature name="Storage">
      <param name="android-package" value="org.apache.cordova.Storage"/>
    </feature>
    <feature name="FileTransfer">
      <param name="android-package" value="org.apache.cordova.FileTransfer"/>
    </feature>
    <feature name="Capture">
      <param name="android-package" value="org.apache.cordova.Capture"/>
    </feature>
    <feature name="Battery">
      <param name="android-package" value="org.apache.cordova.BatteryListener"/>
    </feature>
    <feature name="SplashScreen">
      <param name="android-package" value="org.apache.cordova.SplashScreen"/>
    </feature>
    <feature name="Echo">
      <param name="android-package" value="org.apache.cordova.Echo"/>
    </feature>
    <feature name="Globalization">
      <param name="android-package" value="org.apache.cordova.Globalization"/>
    </feature>
    <feature name="InAppBrowser">
      <param name="android-package" value="org.apache.cordova.InAppBrowser"/>
    </feature>
    <!-- Deprecated plugins element. Remove in 3.0 -->


    <plugins>
        <plugin name="SplashScreen" value="org.apache.cordova.SplashScreen"/>
        <gap:plugin name="de.appplant.cordova.plugin.local-notification" version="0.6.2" />
    </plugins>

</widget>
Run Code Online (Sandbox Code Playgroud)

我在adt插件中使用eclipse.我生成了一个Android应用程序并对其进行了一些修改,因此它可以与phonegap一起使用(它的工作正常,没有本地通知插件).我使用的是cordova 2.9.0版本.我怎么解决这个问题?

drd*_*rej 57

您需要添加一个xml命名空间.

  xmlns:gap="http://phonegap.com/ns/1.0"
Run Code Online (Sandbox Code Playgroud)

你的根xml看起来像这样:

  <widget id="com.example.MyApp" 
    version="1.0.0" xmlns="http://www.w3.org/ns/widgets" 
    xmlns:gap="http://phonegap.com/ns/1.0">
Run Code Online (Sandbox Code Playgroud)

祝好运!

  • 对于`android:something`属性(如@mrmoree的答案中显示的示例),将以下内容添加到`<widget>`标记:`xmlns:android ="http://schemas.android.com/apk/res/机器人">` (14认同)

小智 17

对我来说,问题是我的清单文件中的一个不可解释的属性.将红色标记更改为绿色(请参见屏幕截图),确保已连接Android设备并phonegap run android再次运行.

在AndroidManifest.xml中更改错误的xml属性

使用adb logcat发现构建和运行时问题 对于android,您可以使用logcat输出来调试phonegap/cordova应用程序.在iOS上使用xcode的logcat输出

我通过adb logcat在控制台中运行项目来发现上述问题.

如果您想过滤任何日志文件的输出,可以使用grep后跟关键字(例如error或mergemanifest)轻松完成:

adb logcat | grep error
Run Code Online (Sandbox Code Playgroud)

用logcat中的任何内容替换"error"

  • 或者只是将android命名空间添加到你的xml`xmlns:android ="http://schemas.android.com/apk/res/android"` (4认同)