13

I restarted eclipse and the error changed to "error: Error parsing XML: unbound prefix" on the same line

I am trying to use this plugin in my android phonegap application. It is a local notification plugin. I am getting the error in my config.xml file on this line:

<gap:plugin name="de.appplant.cordova.plugin.local-notification" version="0.6.2" />

There is a similar question about this problem here, but the answer is not related to my problem.

Here is my config.xml file:

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

I am using eclipse with the adt plugin. I generated an android application and made some modification to it so it would work with phonegap (its working fine without the local notification plugin). I am using cordova 2.9.0 version. How can I solve this problem?

Community
  • 1
  • 1
Max Pain
  • 1,217
  • 7
  • 19
  • 33

3 Answers3

57

You need to add a xml namespace.

  xmlns:gap="http://phonegap.com/ns/1.0"

Your root xml schould look like this one:

  <widget id="com.example.MyApp" 
    version="1.0.0" xmlns="http://www.w3.org/ns/widgets" 
    xmlns:gap="http://phonegap.com/ns/1.0">

good luck!

drdrej
  • 904
  • 8
  • 14
  • 14
    For `android:something` properties (like the example shown in @mrmoree's answer), add the following to the `` tag: `xmlns:android="http://schemas.android.com/apk/res/android">` – Ronny Jun 30 '15 at 14:03
  • @drdrej Hi i am using so what wil i write in widget?? – Shaddy Jan 07 '16 at 12:47
18

For me the problem was a not interpretable attribute in my manifest file. change the red marked to the green one (see screenshot), make sure you have your android device connected and run phonegap run android again.

change wrong xml attributes in AndroidManifest.xml

Use adb logcat to discover build and runtime issues For android you can use the logcat output to debug your phonegap/cordova application. On iOS use the logcat output from xcode

i discovered the above problem by running adb logcat from projects root in console.

if you like to filter the output of any logfile you can do easily by using grep followed by your keyword (e.g. error or mergemanifest):

adb logcat | grep error

replace "error" with whatever you are looking for in logcat

mrmoree
  • 412
  • 4
  • 10
0

Thank you very much mrmoree! This thread pointed me in the right direction. I had an similar issue with the final version of the config.xml being built by ionic-cordova, getting this error:

.../platforms/android/app/src/main/res/xml/config.xml:51: AAPT: error: unbound prefix.

I had to switch over the xml tag format to have name="android.permission.CAMERA" platform="android" broken out instead of android:name="android.permission.CAMERA" for it to work. Now it works great.

<platform name="android">
    <config-file parent="/*" target="AndroidManifest.xml">
        <uses-permission name="android.permission.CAMERA" platform="android" />
        <uses-permission name="android.permission.RECORD_AUDIO" platform="android" />
        <uses-permission name="android.permission.MODIFY_AUDIO_SETTINGS" platform="android" />
    </config-file>
</platform>
Shane McCurdy
  • 2,203
  • 1
  • 10
  • 11