walle 官方GitHub地址:https://github.com/Meituan-Dianping/walle
VasDolly 官方GitHub地址:https://github.com/Tencent/VasDolly
VasDolly接入的步骤:
第一步:在Project的build.gradle中添加这行代码
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.1'
classpath 'com.leon.channel:plugin:2.0.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
第二步:在Module的build.gradle中,添加对VasDolly的引用
apply plugin: 'channel'
第三步:在Module工程中去引用helper依赖
api 'com.leon.channel:helper:2.0.1’
第四步:配置签名文件
自动化打包一定要在buildTypes 指定signingConfig signingConfigs.release //gradle 自动打包一定要添加这句,如果是debug包可以不用添加。在Module工程下配置
android {
signingConfigs {
debug {
storeFile file('D:\\DownLoad\\VasDolly-master\\MyApplication\\vasdolly1.jks')
storePassword '123456'
keyAlias = '123456'
keyPassword '123456'
}
release {
storeFile file('D:\\DownLoad\\VasDolly-master\\MyApplication\\vasdolly1.jks')
storePassword '123456'
keyAlias = '123456'
keyPassword '123456'
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release//gradle 自动打包一定要添加这句
}
debug {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.debug //可以没有
}
}
compileSdkVersion 28
defaultConfig {
applicationId "com.cq.myapplication"
minSdkVersion 15
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
}
channel {
//指定渠道文件
channelFile = file("D:/DownLoad/VasDolly-master/MyApplication/channel.txt")
//多渠道包的输出目录,默认为new File(project.buildDir,"channel")
baseOutputDir = new File(project.rootProject.buildDir, "channel")
//多渠道包的命名规则,默认为:
${appName}-${versionName}-${versionCode}-${flavorName}-${buildType}
apkNameFormat = '${appName}-${versionName}-${versionCode}-${flavorName}-${buildType}'
//快速模式:生成渠道包时不进行校验(速度可以提升10倍以上,默认为false)
isFastMode = false
//buildTime的时间格式,默认格式:yyyyMMdd-HHmmss
buildTimeDateFormat = 'yyyyMMdd-HH:mm:ss'
//低内存模式(仅针对V2签名,默认为false):只把签名块、中央目录和EOCD读取到内存,不把最大头
的内容块读取到内存,在手机上合成APK时,可以使用该模式
lowMemory = false
}
rebuildChannel {
//指定渠道文件
channelFile = file("D:\\DownLoad\\VasDolly-master\\VasDolly-master\\channel.txt")
baseDebugApk = new File("D:\\DownLoad\\VasDolly-master\\VasDolly-master\\baseApk\\app-debug.apk")
baseReleaseApk = new File("D:\\DownLoad\\VasDolly-master\\VasDolly-master\\baseApk\\app-debug.apk")
//默认为new File(project.buildDir, "rebuildChannel/debug")
debugOutputDir = new File(project.rootProject.buildDir,"rebuildChannel/debug")
//默认为new File(project.buildDir, "rebuildChannel/release")
releaseOutputDir = new File(project.rootProject.buildDir,"rebuildChannel/release")
//快速模式:生成渠道包时不进行校验(速度可以提升10倍以上,默认为false)
isFastMode = false
//低内存模式(仅针对V2签名,默认为false):只把签名块、中央目录和EOCD读取到内存,不把最大头的内容块读取到内存,在手机上合成APK时,可以使用该模式
lowMemory = false
}
其中,多渠道包的命名规则中,可使用以下字段:
appName : 当前project的name
versionName : 当前Variant的versionName
versionCode : 当前Variant的versionCode
buildType : 当前Variant的buildType,即debug or release
flavorName : 当前的渠道名称
appId : 当前Variant的applicationId
buildTime : 当前编译构建日期时间,时间格式可以自定义,默认格式:yyyyMMdd-HHmmss
第五步:第五步:开始打包,在Android Studio 下的 Terminal 下输入命令行即可
gradlew channelDebug 测试
gradlew channelRelease 正式
gradlew rebuildChannel 利用原有的apk进行多渠道打包