Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error parsing XML: unbound prefix when doing cordova build android #24

Closed
Joustie opened this issue Jan 19, 2016 · 13 comments
Closed

Error parsing XML: unbound prefix when doing cordova build android #24

Joustie opened this issue Jan 19, 2016 · 13 comments

Comments

@Joustie
Copy link

Joustie commented Jan 19, 2016

Hi,
Thanks for making this plugin. I really need this functionality. Unfortunately it breaks my cordova android build with this error:
../platforms/android/build/intermediates/res/armv7/debug/xml/config.xml:43: error: Error parsing XML: unbound prefix

That line says:
<config-file parent="/*" target="AndroidManifest.xml"> <uses-permission android:name="android.permission.CAMERA" /> </config-file>

The root config.xml file used by this installation has the following config platform settings that are used by your plugin:
<platform name="android"> <config-file target="AndroidManifest.xml" parent="/*"> <uses-permission android:name="android.permission.CAMERA" /> </config-file> <preference name="android-manifest/application/@android:name" value="com.joustie.foo.App" /> <icon src="resources/android/icon/drawable-ldpi-icon.png" density="ldpi"/> <icon src="resources/android/icon/drawable-mdpi-icon.png" density="mdpi"/> <icon src="resources/android/icon/drawable-hdpi-icon.png" density="hdpi"/> <icon src="resources/android/icon/drawable-xhdpi-icon.png" density="xhdpi"/> <icon src="resources/android/icon/drawable-xxhdpi-icon.png" density="xxhdpi"/> <icon src="resources/android/icon/drawable-xxxhdpi-icon.png" density="xxxhdpi"/> <splash src="resources/android/splash/drawable-land-ldpi-screen.png" density="land-ldpi"/> <splash src="resources/android/splash/drawable-land-mdpi-screen.png" density="land-mdpi"/> <splash src="resources/android/splash/drawable-land-hdpi-screen.png" density="land-hdpi"/> <splash src="resources/android/splash/drawable-land-xhdpi-screen.png" density="land-xhdpi"/> <splash src="resources/android/splash/drawable-land-xxhdpi-screen.png" density="land-xxhdpi"/> <splash src="resources/android/splash/drawable-land-xxxhdpi-screen.png" density="land-xxxhdpi"/> <splash src="resources/android/splash/drawable-port-ldpi-screen.png" density="port-ldpi"/> <splash src="resources/android/splash/drawable-port-mdpi-screen.png" density="port-mdpi"/> <splash src="resources/android/splash/drawable-port-hdpi-screen.png" density="port-hdpi"/> <splash src="resources/android/splash/drawable-port-xhdpi-screen.png" density="port-xhdpi"/> <splash src="resources/android/splash/drawable-port-xxhdpi-screen.png" density="port-xxhdpi"/> <splash src="resources/android/splash/drawable-port-xxxhdpi-screen.png" density="port-xxxhdpi"/> </platform>

Any idea why android build fails? The AndroidManifest.xml file int he platform directory is correctly updated by your plugin code, but it seems to also alter an 'intermediate' file that is parsed in the android build phase?

@SvenTobback
Copy link

Hi Joustie,

Did you add the Android namespace to the config.xml?

The xmlns:android="http://schemas.android.com/apk/res/android" attribute should be added to the root <widget> tag inside the config.xml if you want to use <tag android:abc>.

Hope this helps.

@Joustie
Copy link
Author

Joustie commented Jan 19, 2016

Hi,

That was it. Thank you very much!

Regards,
Joost

Op dinsdag 19 januari 2016 heeft SvenTobback notifications@github.com het
volgende geschreven:

Hi Joustie,

Did you add the Android namespace to the config.xml?

The xmlns:android="http://schemas.android.com/apk/res/android" attribute
should be added to the root tag inside the config.xml if you
want to use .

Hope this helps.


Reply to this email directly or view it on GitHub
#24 (comment)
.

Joost Evertse
Private email: joustie@gmail.com
Web: http://www.joustie.nl
Twitter: joustie
Hyves: http://joustie.hyves.nl
Facebook: http://www.facebook.com/profile.php?id=1402911295&ref=name

@dpa99c
Copy link
Owner

dpa99c commented Jan 20, 2016

Glad you got it sorted - I'll update the plugin documentation to state that this namespace needs to be included in config.xml

@Edison4mobile
Copy link

@SvenTobback
you are best.

@rhanesoghlyan
Copy link

@SvenTobback I've got this error message when building project in Android platform.

The prefix "ns1" for attribute "ns1:name" associated with an element type "meta-data" is not bound.

This is my widget
<widget id="test" version="0.0.3" xmlns="http://www.w3.org/ns/widgets" xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools">

And my config file tag:
<hook src="package-hooks/android_custom_resources.js" type="after_prepare" /> <hook src="package-hooks/android_custom_values.js" type="after_prepare" /> <config-file parent="./application" target="AndroidManifest.xml"> <meta-data android:name="com.google.firebase.messaging.default_notification_icon" android:resource="@drawable/notification_icon" /> <meta-data android:name="com.google.firebase.messaging.default_notification_color" android:resource="@color/red" /> </config-file>

@distinctdan
Copy link

distinctdan commented Mar 29, 2019

Is there a way to programmatically set it on the widget? Editing anything in the build process by hand seems like it would defeat the whole point of this plugin. Vanilla cordova has the same issue, so maybe it's really a cordova issue instead of with custom-config.

@distinctdan
Copy link

distinctdan commented Mar 29, 2019

I've tried manually adding it, but it gets overwritten when cordova prepares. Not sure what to do here. I've opened an issue on the android project: apache/cordova-android#702

@distinctdan
Copy link

Got it figured out, I didn't realize this was talking about the main cordova/config.xml file, not the one in the platforms folder that was throwing the error.

@darrensapalo
Copy link

Thanks to @distinctdan for giving me an idea of where I'm going wrong with how I was solving this same problem of mine.

For ionic-v3 users building on the Android platform, I detailed exactly which config.xml file to edit in your project folder on this ionic forum post.

@gsingh0101
Copy link

Hi Joustie,

Did you add the Android namespace to the config.xml?

The xmlns:android="http://schemas.android.com/apk/res/android" attribute should be added to the root <widget> tag inside the config.xml if you want to use <tag android:abc>.

Hope this helps.

It worked, thanks

@sreenumalae
Copy link

Hi Joustie,

Did you add the Android namespace to the config.xml?

The xmlns:android="http://schemas.android.com/apk/res/android" attribute should be added to the root <widget> tag inside the config.xml if you want to use <tag android:abc>.

Hope this helps.

Hi @SvenTobback
I have similar error. Clearly mention in the below link
https://forum.ionicframework.com/t/error-while-building-release-apk/176575/7
I'm getting error while I'm trying to build release apk (Cordova build android --release)
please help me out.

@ssnielsen
Copy link

@rhanesoghlyan This might be a long shot, but here goes... I'm running into the same problem as you - did you ever find a viable solution?

@l3ender
Copy link

l3ender commented Jul 22, 2022

I ran into this issue when using edit-config in config.xml. As the file is copied to app/src/main/res/xml/config.xml, it also is processed during compilation. Therefore I needed to add the same namespace to the widget element in config.xml:

<widget ...
    xmlns="http://www.w3.org/ns/widgets"
    xmlns:cdv="http://cordova.apache.org/ns/1.0"
    xmlns:android="http://schemas.android.com/apk/res/android">

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests