最近在学习插件化开发,之前看的是VirtualApk,但是从2018年之后,已经没有人维护了,所以换成360的Replugin,先上效果图
环境搭建:
Android stuido 4.0
gradle 3.1.3+4.4
replugin 2.3.1
com.android.support:appcompat-v7
本次使用的是内部插件方式加载
项目结构图
环境搭建:
因为是在同一个项目下的,所以在project中放入宿主和插件导入
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath "com.android.tools.build:gradle:3.1.3"
classpath 'com.qihoo360.replugin:replugin-host-gradle:2.3.1'
classpath 'com.qihoo360.replugin:replugin-plugin-gradle:2.3.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
说明:gradle版本如果升级用太高的话,是会存在问题,各种报错,有可能是RePluginHostConfig文件不能自动生成的错,也有可能是build.gradle中语法报错,到处都是坑
宿主app:
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
buildToolsVersion '27.0.3'
defaultConfig {
applicationId "com.example.pluginprojectonly"
minSdkVersion 16
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled