1

First I generate some android libraries dynamically whose contain an xml file in src/main/res/xml/config.xml which include library specific data.

Next, when I build my android application, with the generated libraries as depencencies, I would expect that the generated apk contains the xml config file merged with all librairies xml config files, but it doesn't.

Plugins Android manifests are merged in one file, is there something to do to make it work the same for xml files ? Is this even actually possible ?

Each plugin has a config file which contain for example:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<plugins>
    <feature name="Plugin1">
        <param name="package" value="com.example.Plugin1"/>
    </feature>
</plugins>

and I would expect that the apk contains the xml config file with the content, for 3 plugins:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<plugins>
    <feature name="Plugin1">
        <param name="package" value="com.example.Plugin1"/>
    </feature>

    <feature name="Plugin2">
        <param name="package" value="com.example.Plugin2"/>
    </feature>

    <feature name="Plugin3">
        <param name="package" value="com.example.Plugin3"/>
    </feature>
</plugins>

Thanks

reaper
  • 398
  • 3
  • 15

1 Answers1

0

I don't think it's possible the way you're suggesting. An alternative worth exploring would be to create XML files as assets, with unique names (e.g. assets/plugin-(plugin-name).xml).

This has two properties that would make this possible at compile time and at runtime:

  • as filenames are unique, you would end up having a collection of files in your asset directory that would not be overwritten (following your example, could be assets/plugin-Plugin1.xml, assets/plugin-Plugin2.xml, assets/plugin-Plugin3.xml),
  • as they are in the assets directory, they can be listed.

With this, you can have a similar effect to what you're looking for at runtime. The only addition worth mentioning would be to include a suitable Proguard rules file in each plugin you create, should you minify your APK, as I understand your plugins will be instantiated at runtime by reflection.

Xavier Rubio Jansana
  • 6,388
  • 1
  • 27
  • 50