GitHub - didi/VirtualAPK: A powerful and lightweight plugin framework for Androi...
source link: https://github.com/didi/VirtualAPK
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Android 9.0 supported! Please use the lastest release.
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.
Supported Features
Feature | Detail |
---|---|
Supported components | Activity, Service, Receiver and Provider |
Manually register components in AndroidManifest.xml | No need |
Access host app classes and resources | Supported |
PendingIntent | Supported |
Supported Android features | Almost all features |
Compatibility | Almost all devices |
Building system | Gradle plugin |
Supported Android versions | API 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()
.
@Override
protected void attachBaseContext(Context base) {
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!
String pluginPath = Environment.getExternalStorageDirectory().getAbsolutePath().concat("/Test.apk");
File plugin = new File(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`.
Intent intent = new Intent();
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?
License
VirtualAPK is licensed under the Apache License 2.0. See the LICENSE file.
Recommend
-
170
1 介绍Android 插件化技术是比较热门领域,VirtualAPK 是滴滴2017年6月3号开源,框架功能完备,支持 Android 四大组件,良好的兼容性,且入侵性较低,作为加载耦合插件方案是较好选择。兼容市面上几乎所有的 Android 手机,这一点已经在滴滴出行客户端中得到验证;...
-
75
Android开源框架源码鉴赏:VirtualAPK
-
53
README.md Neptune
-
31
-
19
什么是插件化? 插件化包括宿主和插件2部分。把需要实现的模块或功能独立的提取出来,比如相册,每个模块相当于一个独立的apk,这个apk就是一个插件。有一个加载相册插件apk的App叫做宿主,宿主是一个普通的App,但包含了加载插...
-
10
滴滴插件化方案 VirtualApk 源码解析
-
7
DEX控制流混淆 · BlackObfuscator English Version 本项目针对Android APK DEX控制流混淆,在不会改变应用原有逻辑的前提下,会将原始...
-
10
Android's built-in screen recorder gets its 'show touches' option back in Android 13 DP2 By Ryne Hager Published 21 hours ago ...
-
7
WhatsApp Beta now lets you change your preferred language in-app, beating Android 13 to it By Manuel Vonau Published 30 minutes ago
-
8
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK