Mr. Shiny and New 安宇
Mr. Shiny and New 安宇

Reputation: 13908

What is cordova.xml for in Phonegap?

While trying to debug a Phonegap error message ("Call to OpenGL ES api with no current context" which doesn't appear to be causing any problems), I came across a newer version of the cordova.xml file which ships with PhoneGap 1.6 and has the following line in it:

<preference name="classicRender" value="true" />

Adding this line to my copy of cordova.xml didn't do anything. But then I also noticed the comments and other lines in that file regarding access origins, and I noticed that my app has the access origin set to 127.0.0.1 but all my code is on a remote server, and this doesn't seem to matter.

I searched for documentation but didn't find any.

So I have to ask: what is the cordova.xml file for, what directives can be put in it, and what are they supposed to do?

Upvotes: 6

Views: 5473

Answers (1)

Gunnar Karlsson
Gunnar Karlsson

Reputation: 28470

The cordova.xml file is a configuration file that specifies settings for whitelisted urls, log level, and rendering. The file was previously called phonegap.xml and was renamed when Adobe/Nitobi donated the PhoneGap codebase to the Apache Software Foundation (ASF) for incubation.

The file includes three settings.

First is:

<access origin>

which specifies an approved list of URLs that can be loaded. These urls are added to the whitelist cache in the DroidGap class. Only URLs on the whitelist can be loaded in the Cordova webview or a new browser instance.

Second is:

<log level> 

which specifies log level for debugging on Android . It can be set to ERROR, WARN, INFO, DEBUG or VERBOSE (default=ERROR).

Third is:

<preference name="classicRender" />

which sets the field

private boolean classicRender;

in the DroidGap class. The only reference to what it actually does that I can find is in this commit to Cordova:

   if(android.os.Build.VERSION.SDK_INT < 14 && this.classicRender)
     {
         //This hack fixes legacy PhoneGap apps
         //We should be using real pixels, not pretend pixels
   ...

Perhaps it's more useful to know that it's apparently being removed since it doesn't work properly.

The cordova.xml is parsed in the DroidGap class, in the loadConfiguration() method:

private void loadConfiguration() {
     int id = getResources().getIdentifier("cordova", "xml", getPackageName());
     ...
     XmlResourceParser xml = getResources().getXml(id);
     etc...

See line 1252 in the DroidGap class for full loadConfiguration() method. All three attributes are parsed but as per above link it appears the classicRender setting doesn't work and can be ignored.

Upvotes: 15

Related Questions