Android multi-channel package

walle official GitHub Address: https://github.com/Meituan-Dianping/walle

VasDolly official GitHub Address : https://github.com/Tencent/VasDolly

VasDolly access steps:

The first step: add this line of code in the Project of 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
    }
}

Step two: Module of build.gradle, add a reference to the VasDolly

apply plugin: 'channel'

The third step: In Module to the project references helper-dependent

api 'com.leon.channel:helper:2.0.1’

Step Four: Configure signature file

Automated Packaging sure to specify signingConfig signingConfigs.release // gradle in buildTypes automatic packing Be sure to add the phrase, if you can not add a debug package. Module configuration in the project

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
}

Among them, naming multi-channel package, you can use the following fields:

appName: The current project's name

versionName: Current Variant of versionName

versionCode: Current Variant of versionCode

buildType : 当前Variant的buildType,即debug or release

flavorName: The current channel name

appId: Current Variant of applicationId

buildTime: current compilation build date and time, you can customize the time format, the default format: yyyyMMdd-HHmmss

Step Five: Step 5: Start packing, you can enter the command line in Terminal in Android Studio

gradlew channelDebug test

gradlew channelRelease official

gradlew rebuildChannel apk using the original multi-channel package

Success, perfect!

Published 49 original articles · won praise 2 · Views 8572

Guess you like

Origin blog.csdn.net/yangjunjin/article/details/93760974