Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
singwhatiwanna committed Jun 29, 2017
2 parents 9558c39 + c4b301c commit ac5f393
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 46 deletions.
34 changes: 25 additions & 9 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,28 @@
### How to send Pull request
Welcome to send pull request to VirtualAPK, but you should read the following notes before your contribution.
# Contribution Guideline

1. Branch: only branch ```dev``` will accept pull request, so not send your pull request to other branch.
2. Code style and name format: please refer to the code style of Android and VirtualAPK.
3. Format of commit message when submit code by git: only English message that spelled Correctly is accepted.
4. Test: you should test your code before sending pull request, It's recommended that add ```device mode```, ```API version```, ```log```, ```photos``` and etc with your pull request.
Thanks for considering to contribute this project. All issues and pull requests are highly appreciated.

```Note```: make sure the code of your pull request is under the [Apache License 2.0](https://github.com/didi/VirtualAPK/blob/master/LICENSE).
## Pull Requests

### How to make issue
Welcome to make issue for VirtualAPK, be sure to describe problems explicitly in the issue. It's also recommended that add ```device mode```, ```API version```, ```log```, ```photos``` in the issue.
Before sending pull request to this project, please read and follow guidelines below.

1. Branch: We only accept pull request on `dev` branch.
2. Coding style: Follow the coding style used in VirtualAPK.
3. Commit message: Use English and be aware of your spell.
4. Test: Make sure to test your code.

Add device mode, API version, related log, screenshots and other related information in your pull request if possible.

NOTE: We assume all your contribution can be licensed under the [Apache License 2.0](https://github.com/didi/VirtualAPK/blob/master/LICENSE).

## Issues

We love clearly described issues. :)

Following information can help us to resolve the issue faster.

* Device mode and hardware information.
* API version.
* Logs.
* Screenshots.
* Steps to reproduce the issue.
94 changes: 57 additions & 37 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,43 +3,49 @@
[![Release Version](https://img.shields.io/badge/release-0.9.0-red.svg)](https://github.com/didi/VirtualAPK/releases)
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/didi/VirtualAPK/pulls)

VirtualAPK is a powerful but lightweight plugin framework for Android, it can load an apk file dynamically, then the loaded apk file which is called LoadedPlugin by us can be treated as applications installed.

Through VirtualAPK, developers can visit Class and Resources in LoadedPlugin, more important, can visit Android components(Activity/Service/Receiver/Provider) just like they are registered in Android.
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](imgs/va.png)
# Feature supported

|Feature|Detail
# Supported Features

| Feature | Detail |
|:-------------|:-------------:|
| Supported components |Activity / Service / Receiver / Provider
| Components need to register in AndroidManifest.xml |Not needed
| Plugin can depend on host app| Yes
| Support PendingIntent| Yes
| Supported Android features| Almost all features
| Compatible devices| Almost all devices
| How to build plugin apk |Gradle plugin
| Supported Android versions |API 15 +
| 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 the following dependency in the build.gradle in root path of host project:

## Host Project

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

``` java
dependencies {
classpath 'com.didi.virtualapk:gradle:0.9.0'
}
```

Apply plugin in the build.gradle of application module:
Apply plugin in application module of `build.gradle`.

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

Add the following dependency in the build.gradle of application module:
Compile VirtualAPK in application module of `build.gradle`.

``` java
compile 'com.didi.virtualapk:core:0.9.0'
```

Then add initial code in attachBaseContext method of application:
Initialize `PluginManager` in `YourApplication::attachBaseContext()`.

``` java
@Override
protected void attachBaseContext(Context base) {
Expand All @@ -48,7 +54,8 @@ protected void attachBaseContext(Context base) {
}
```

Lastly, add the following proguard rules to your application module:
Modify proguard rules to keep VirtualAPK related files.

```
-keep class com.didi.virtualapk.internal.VAInstrumentation { *; }
-keep class com.didi.virtualapk.internal.PluginContentResolver { *; }
Expand All @@ -58,52 +65,65 @@ Lastly, add the following proguard rules to your application module:
-keep class android.** { *; }
```

Now, you can load an apk as you wish, for example:
Finally, load an APK and have fun!

``` java
String pluginPath = Environment.getExternalStorageDirectory().getAbsolutePath().concat("/Test.apk");
File plugin = new File(pluginPath);
PluginManager.getInstance(base).loadPlugin(plugin);

//suppose "com.didi.virtualapk.demo" is the package name of plugin apk.
// 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 the following dependency in the build.gradle in root path of plugin project:

## Plugin Project

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

``` java
dependencies {
classpath 'com.didi.virtualapk:gradle:0.9.0'
}
```

Then apply plugin in the build.gradle of application module and config VirtualAPK.
Apply plugin in application module of `build.gradle`.

Note : put the following code at the end 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: true.
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.
}
```
# Develop guide

1. See the [wiki](https://github.com/didi/VirtualAPK/wiki)
2. See the sample project [PluginDemo](https://github.com/didi/VirtualAPK/tree/master/PluginDemo)
3. Read the [source code](https://github.com/didi/VirtualAPK/tree/master/CoreLibrary)
# Developer guide

* API document [wiki](https://github.com/didi/VirtualAPK/wiki)
* Sample project [PluginDemo](https://github.com/didi/VirtualAPK/tree/master/PluginDemo)
* Read [core library source code](https://github.com/didi/VirtualAPK/tree/master/CoreLibrary)

# Known issues
- not support notifications with custom layout in plugin
- not support transition animations with animation resources in plugin

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

# Contributing
Welcome to contribute to VirtualAPK, you can contribute issues or pull requests, see the [Contributing Guide](CONTRIBUTING.md).

Welcome to contribute by creating issues or sending pull requests. See [Contributing Guide](CONTRIBUTING.md) for guidelines.

# Who is using VirtualAPK?
<img src="imgs/didi.png" width="78px" align="center" alt="滴滴出现"/> <img src="imgs/uber-china.png" width="78px" align="center" alt="Uber中国"/>

<img src="imgs/didi.png" width="78px" align="center" alt="滴滴出行"/> <img src="imgs/uber-china.png" width="78px" align="center" alt="Uber中国"/>

# License
VirtualAPK is under the Apache License 2.0, see the [LICENSE](LICENSE) file.

VirtualAPK is licensed under the Apache License 2.0. See the [LICENSE](LICENSE) file.

0 comments on commit ac5f393

Please sign in to comment.