1

I use aapt's --rename-manifest-package to generate env specific packages.

See this question

the package names in prod, I use

com.xxx.app

for uat env, I use

com.xxx.app.uat

it works fine until I added phonegap, I'm using codorva 2.2, it gives me below error

12-12 19:02:36.156: E/PluginManager(13188):     =====================================================================================
12-12 19:02:36.156: E/PluginManager(13188): ERROR: plugin.xml is missing.  Add       res/xml/plugins.xml to your project.
12-12 19:02:36.156: E/PluginManager(13188): https://git-wip-us.apache.org/repos/asf?     p=incubator-cordova-android.git;a=blob;f=framework/res/xml/plugins.xml  
12-12 19:02:36.156: E/PluginManager(13188): =====================================================================================

I finally traced down to below code in PluginManager

int id = this.ctx.getActivity().getResources().getIdentifier("config", "xml", this.ctx.getActivity().getPackageName());
...
XmlResourceParser xml = this.ctx.getActivity().getResources().getXml(id);

the id is 0 which means it failed to reference the config.xml getActivity().getPackgeName() gives replaced package name - "com.xxx.app.uat"

it looks like .getResources().getIdentifer() was not updated to new package... could it be a bug from android?

In my test case, if I use R.xml.config, it referenced config.xml without issues.

the problem is I can't change PluginsManager which is a part of Phonegap codebase...

Community
  • 1
  • 1
Rick Li
  • 1,457
  • 2
  • 14
  • 19
  • Did you update the .jar file along with things when you switched to cordova 2.2? – Simon MacDonald Dec 12 '12 at 16:00
  • Yes, updated, it's not cordova not working, it works well if I don't set --rename-manifest-package – Rick Li Dec 13 '12 at 10:46
  • Did you ever find a solution for this? trying to setup packages for test and dev, but getting the same error – tik27 Jun 27 '13 at 17:27
  • @tik27 No, I ended up by using string replacing in build script. – Rick Li Jun 27 '13 at 23:48
  • @Rick Li, I am experiencing the same problem. When you mention you ended up using a string replacement in the build script, what string are you replacing ? The package="..." in the manifest or did you change all your package structure at build time ? – yann.debonnel Jul 31 '13 at 15:49
  • @yann.debonnel yes, in build time, I use groovy script to change the package structure and the package name... – Rick Li Jul 31 '13 at 23:45

1 Answers1

1

I've experienced the same bug, but I approached it differently then Rick Li. The app first tries to load the resource using the context's package name, if that does not work (id still 0), the app tries from the activity's class package name.

int id = this.ctx.getActivity().getResources().getIdentifier("config", "xml", this.ctx.getActivity().getPackageName());
        if (id == 0) {
            // could not find the resource id, maybe we are using the wrong package name ? (the package name could have been changed via aapt at build time).
            id = this.ctx.getActivity().getResources().getIdentifier("config", "xml", this.ctx.getActivity().getClass().getPackage().getName());
            if(id == 0){
                this.pluginConfigurationMissing();
                //We have the error, we need to exit without crashing!
                return;
            }
        }
yann.debonnel
  • 766
  • 9
  • 22