Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cordova default config.xml URI is not registered

I'm trying to build an android app by using Cordova. However, after I created the project, added platform android, and import it into Android Studio. I met some problems with the config.xml. I didn't change anything but I still get this error.

It says URI is not registered for xmlns:cdv.

The entire xml file is this:

<?xml version='1.0' encoding='utf-8'?>
<widget id="xxx.xxx.xxx" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
    <preference name="loglevel" value="DEBUG" />
    <feature name="Whitelist">
        <param name="android-package" value="org.apache.cordova.whitelist.WhitelistPlugin" />
        <param name="onload" value="true" />
    </feature>
    <allow-intent href="market:*" />
    <name>xxxx</name>
    <description>
        A sample Apache Cordova application that responds to the deviceready event.
    </description>
    <author email="[email protected]" href="http://cordova.io">
        Apache Cordova Team
    </author>
    <content src="view/index.html" />
    <access origin="*" />
    <allow-intent href="http://*/*" />
    <allow-intent href="https://*/*" />
    <allow-intent href="tel:*" />
    <allow-intent href="sms:*" />
    <allow-intent href="mailto:*" />
    <allow-intent href="geo:*" />
    <feature name="SplashScreen">
        <param name="android-package" value="org.apache.cordova.splashscreen.SplashScreen" />
        <param name="onload" value="true" />
    </feature>
    <platform name="android">
        <icon src="res/drawable-ldpi/icon.png" density="ldpi" />
        <icon src="res/android-mdpi/icon.png" density="mdpi" />
        <icon src="res/android-hdpi/icon.png" density="hdpi" />
        <icon src="res/android-xhdpi/icon.png" density="xhdpi" />
    </platform>
</widget>
like image 683
TommyQu Avatar asked Jul 28 '15 21:07

TommyQu


People also ask

Where is config xml in cordova?

The Cordova config. xml file is the global configuration file of the application. The Cordova configuration file is a mandatory XML file that contains application metadata, and is stored in the root directory of the app. The file is automatically generated when you create a Cordova application.

What is config xml file in cordova?

config. xml is a global configuration file that controls many aspects of a cordova application's behavior. This platform-agnostic XML file is arranged based on the W3C's Packaged Web Apps (Widgets) specification, and extended to specify core Cordova API features, plugins, and platform-specific settings.

How do I add a plugin to config xml cordova?

When adding plugins or platforms, use the --save flag to add them to config. xml. Ex: cordova platform add android --save. Existing projects can use cordova plugin save and cordova platform save commands to save all previously installed plugins and platforms into your project's config.

Where do I find config xml?

Each WebLogic Server domain contains a central configuration file called the config. xml, which is stored in the DOMAIN_HOME\config directory. Both the Admin Server and the Managed Servers derive their run-time configuration information from the config.


1 Answers

Solution:

Add both files:

  • http://www.w3.org/ns/widgets
  • http://cordova.apache.org/ns/1.0

To your Ignored Schemas and DTDs at:

File > Settings > Languages & Frameworks > Schemas and DTDs > Ignored Schemas and DTDs.

TL;DR:

Android Studio is incorrectly assuming that these XML Namespaces are used to validate your xml (they are not), so it wants you to register the URI. This is unnecessary since these XML Namespace declarations do not reference anything and do not validate anything -- they exist only as an arbitrary and unique name.

This was a tough concept for me while I was looking into this, so for clarity I'll include a direct quote from the W3C Recommendation:

The namespace name, to serve its intended purpose, SHOULD have the characteristics of uniqueness and persistence. It is not a goal that it be directly usable for retrieval of a schema (if any exists).

Hence, the solution is to ignore the URI since it does not actually reference a schema.

like image 85
Design.Garden Avatar answered Oct 12 '22 00:10

Design.Garden