Skip to content
This repository was archived by the owner on Apr 15, 2026. It is now read-only.

Repository files navigation

Android 9.0 supported! Please use the lastest release.

VirtualAPK

licenseRelease VersionPRs Welcome

VirtualAPK is a powerful yet lightweight plugin framework for Android. It can dynamically load and run an APK file (we call it LoadedPlugin) seamlessly as an installed application. Developers can use any Class, Resources, Activity, Service, Receiver and Provider in LoadedPlugin as if they are registered in app's manifest file.

VirtualAPK

Supported Features

FeatureDetail
Supported componentsActivity, Service, Receiver and Provider
Manually register components in AndroidManifest.xmlNo need
Access host app classes and resourcesSupported
PendingIntentSupported
Supported Android featuresAlmost all features
CompatibilityAlmost all devices
Building systemGradle plugin
Supported Android versionsAPI Level 15+

Getting started

Host Project

Add a dependency in build.gradle in root of host project as following.

dependencies {
classpath'com.didi.virtualapk:gradle:0.9.8.6'
}

Apply plugin in application module of build.gradle.

apply plugin: 'com.didi.virtualapk.host'

Compile VirtualAPK in application module of build.gradle.

compile'com.didi.virtualapk:core:0.9.8'

Initialize PluginManager in YourApplication::attachBaseContext().

@OverrideprotectedvoidattachBaseContext(Contextbase) {
super.attachBaseContext(base);
PluginManager.getInstance(base).init();
}

Modify proguard rules to keep VirtualAPK related files.

-keep class com.didi.virtualapk.internal.VAInstrumentation { *; }
-keep class com.didi.virtualapk.internal.PluginContentResolver { *; }
-dontwarn com.didi.virtualapk.**
-dontwarn android.**
-keep class android.** { *; }

Finally, load an APK and have fun!

StringpluginPath = Environment.getExternalStorageDirectory().getAbsolutePath().concat("/Test.apk");
Fileplugin = newFile(pluginPath);
PluginManager.getInstance(base).loadPlugin(plugin);
// Given "com.didi.virtualapk.demo" is the package name of plugin APK, // and there is an activity called `MainActivity`.Intentintent = newIntent();
intent.setClassName("com.didi.virtualapk.demo", "com.didi.virtualapk.demo.MainActivity");
startActivity(intent);

Plugin Project

Add a dependency in build.gradle in root of plugin project as following.

dependencies {
classpath'com.didi.virtualapk:gradle:0.9.8.6'
}

Apply plugin in application module of build.gradle.

apply plugin: 'com.didi.virtualapk.plugin'

Config VirtualAPK. Remember to put following lines at the end of build.gradle.

virtualApk {
packageId = 0x6f // The package id of Resources.
targetHost='source/host/app' // The path of application module in host project.
applyHostMapping = true // [Optional] Default value is true. }

Developer guide

Known issues

  • Notifications with custom layout are not supported in plugin.
  • Transition animations with animation resources are not supported in plugin.

Contributing

Welcome to contribute by creating issues or sending pull requests. See Contributing Guide for guidelines.

Who is using VirtualAPK?

滴滴出行Uber中国

License

VirtualAPK is licensed under the Apache License 2.0. See the LICENSE file.

About

A powerful and lightweight plugin framework for Android

Resources

Contributing

Stars

9.1k stars

Watchers

339 watching

Forks

Releases

Packages

Used by

Contributors

Languages