VirtualAPK

A powerful and lightweight plugin framework for Android

  • 所有者: didi/VirtualAPK
  • 平台:
  • 許可證: Apache License 2.0
  • 分類:
  • 主題:
  • 喜歡:
    0
      比較:

Github星跟蹤圖

Android 9.0 supported! Please use the lastest release.

license
Release Version
PRs 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, 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.

主要指標

概覽
名稱與所有者didi/VirtualAPK
主編程語言Java
編程語言Java (語言數: 3)
平台
許可證Apache License 2.0
所有者活动
創建於2017-06-29 07:25:05
推送於2023-07-13 22:06:36
最后一次提交2018-12-25 15:42:16
發布數6
最新版本名稱gradle-0.9.8.6 (發布於 2018-09-06 20:02:52)
第一版名稱0.9.0 (發布於 )
用户参与
星數9k
關注者數342
派生數1.5k
提交數114
已啟用問題?
問題數358
打開的問題數114
拉請求數9
打開的拉請求數7
關閉的拉請求數17
项目设置
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?