VirtualAPK
A powerful and lightweight plugin framework for Android
VirtualAPK is an Android framework from Didi that lets a main app dynamically load and run additional APK files as plugins at runtime, without those plugins needing to be installed on the device.
VirtualAPK is a framework for Android apps that lets a main app load and run additional APK files without those extra apps being formally installed on the device. An APK file is the standard package format for Android apps, and normally an app can only use code and resources that were baked into it at build time. VirtualAPK changes that by treating external APK files as plugins that the host app can pull in and execute on the fly.
For developers, this means you can split a large Android application into a core app and several plugin APKs. The plugin APKs do not need to be listed in the host app's manifest file, which is normally required for Android components like activities, services, and content providers. VirtualAPK handles that registration step automatically at runtime. Plugin code can also access classes and resources from the host app, and the host app can launch screens from a plugin just as if they were part of the original build.
The setup involves two sides: the host project (the main app) and the plugin project (the add-on APK). Both require adding VirtualAPK's Gradle build plugin to their configuration files. On the host side, you initialize a PluginManager when the app starts, then call a load method to bring in an APK file from storage. On the plugin side, you configure a package ID and point it at the host project's source so the build system can wire them together correctly.
The framework supports Activities, Services, Broadcast Receivers, and Content Providers inside plugins. It works on Android API level 15 and above, covering nearly all devices. Known limitations include no support for notifications with custom layouts in plugins and no support for certain transition animations.
VirtualAPK was created by Didi, the ride-hailing company behind the Didi Chuxing app, and was also used by Uber China. It is released under the Apache License 2.0.
Where it fits
- Split a large Android app into a core host app and plugin APKs so users download only the features they need.
- Update specific app features by pushing a new plugin APK without requiring a full update from the Play Store.
- Load a partner's plugin APK inside your host Android app to extend functionality without merging their code at build time.