VirtualAPK


Source link: https://github.com/didi/VirtualAPK

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.1' 
}

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.1'

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.content.pm.** -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.1' 
}

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.

Resources

A very simple library to change font to all of your views. This library will make your application have a default font display. Your application will not be affected by changes to the font type from the settings menu.

Android lib for easy set up custom font, can use for TextView, Button, CheckBox and EditText.

Historian is a custom implementation of Timber.Tree, which is popular logging library.

Historian can save device's logs into dedicated SQLite database, so that your users can send the file to a bug report mail to you.

Custom Android Bubbleview with curved Bezier Paths.

bodylookin is a IntelliJ IDEA-based IDE viewer plugin for bodymovin and Lottie libraries.

A mini and excellent Router Framework.

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes