赞
踩
滴滴 VirtualApk git地址:https://github.com/didi/VirtualAPK
Demo git地址:https://github.com/caixiaoxu/DiDiVirtualApkDemo
classpath ‘com.android.tools.build:gradle:3.0.0’
distributionUrl=https://services.gradle.org/distributions/gradle-4.6-all.zip
dependencies {
classpath 'com.didi.virtualapk:gradle:0.9.8.6'
}
apply plugin: 'com.didi.virtualapk.host'
dependencies {
compile 'com.didi.virtualapk:core:0.9.8'
}
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
PluginManager.getInstance(base).init();
}
//apk路径
File plugin = new File(Environment.getExternalStorageDirectory(), "PluginSub.apk");
if (plugin.exists()) {
try {
PluginManager.getInstance(this).loadPlugin(plugin);
} catch (Exception e) {
e.printStackTrace();
}
}
Intent intent = new Intent();
intent.setClassName("com.lsy.pluginsub","com.lsy.pluginsub.PluginMainActivity");
startActivity(intent);
dependencies {
classpath 'com.didi.virtualapk:gradle:0.9.8.6'
}
apply plugin: 'com.didi.virtualapk.plugin'
virtualApk {
packageId = 0x6f // PackageId值,在[0x02, 0x7E]之间取值.
targetHost='../PluginMain/app' // 宿主项目路径
applyHostMapping = true // 默认为true,混淆时候生成的映射表保持一致
}
gradlew(./gradlew) clean assemblePlugin
或者:
gradle clean assemblePlugin
-----------------编译报错及解决-----------------
> Failed to notify project evaluation listener.
> the packageId must be in [0x02, 0x7E].
> Cannot invoke method onProjectAfterEvaluate() on null object
> Failed to notify project evaluation listener.
> Can't find /Users/Lsy/AndroidStudioProjects/DiDiVirtualApkDemo/PluginMain/app/build/VAHost/versions.txt, please check up your host application
need apply com.didi.virtualapk.host in build.gradle of host application
> Cannot invoke method onProjectAfterEvaluate() on null object
> Failed to notify project evaluation listener.
> Can't using incremental dexing mode, please add 'android.useDexArchive=false' in gradle.properties of :app.
> Cannot invoke method onProjectAfterEvaluate() on null object
> Required entry 'activity_plugin_main' but got 'abc_select_dialog_material', This is seems to unsupport the buildToolsRevision: 29.0.2.
-----------------运行报错及解决-----------------
Caused by: android.content.pm.PackageParser$PackageParserException: Package /storage/emulated/0/PluginSub.apk has no certificates at entry AndroidManifest.xml
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。