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

Open Weather API Wrapper is an Android wrapper for the APIs of https://openweathermap.org. This library handles all the network operations and parameter validations on behalf of the developer.

A fast annotation processor to make your objects Parcelable without writing any of the boilerplate.

A small customizable library useful to handle an gallery image pick action built-in your app.

Handling Android Permission Rationale Properly.

Android Instagram Connector: use Instagram API.

This application helps you to connect to instagram API i two simple steps.

Android library that adds methods isForeground / isBackground / isReturnedFromBackground.

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