Plugins architecture for an Android app? [closed]

I have done a framework that works like Robo-guice with some of its primary IoC functions. (Cut down on boilerplate codes that load views/service etc…)

But the core of which, I believe is the solution to your problem, is the ability to load separate APK “plugin” files, that includes “res” as well as <layouts>.xml files. The <layouts>.xml file can be independently inflated by the classes within that APK. That is, you can load a CustomView (that inflates its own <layout>.xml) into an originating/parent App. All this is done without the Parent App APK knowing how the UI was inflated in the plugin APK.

Example of what I mean:
I have a Mapping App, the framework will dynamically scan installed APK that matches the “contract” for a “add-on function” plugin, and loads the UI specific to it onto the App’s View as a floating panel.

I would say a plugin framework for Android is do-able, as Android has most if not all of the necessary built in APIs to accomplish this.

These are your friends in this area of plugin development for Android:

  1. PackageManager (Scan install packages, aka Plugins)
  2. DexClassLoader (ClassNotFoundException will be a pain if you don’t use the correct ClassLoader btw)
  3. Java Reflection

Leave a Comment