Coder Social home page Coder Social logo

vasdolly's Introduction

license Release Version PRs Welcome wiki

简介

VasDolly是一种快速多渠道打包工具,同时支持基于V1签名和V2签名进行多渠道打包。插件本身会自动检测Apk使用的签名类别,并选择合适的多渠道打包方式,对使用者来说完全透明。 V1.1.6版本已支持Android Gradle Plugin 3.0,欢迎使用!

目前Gradle Plugin 2.2以上默认开启V2签名,所以如果想关闭V2签名,可将下面的v2SigningEnabled设置为false。

signingConfigs {
        release {
            ...
            v1SigningEnabled true
            v2SigningEnabled false
        }

        debug {
            ...
            v1SigningEnabled true
            v2SigningEnabled false
        }
    }

接入流程

添加对VasDolly Plugin的依赖

在根工程的build.gradle中,添加对打包Plugin的依赖:

dependencies {
        classpath 'com.android.tools.build:gradle:3.0.0'
        classpath 'com.leon.channel:plugin:1.1.7'
}

引用VasDolly Plugin

在主App工程的build.gradle中,添加对VasDolly Plugin的引用:

apply plugin: 'channel'

添加对VasDolly helper类库的依赖

在主App工程的build.gradle中,添加读取渠道信息的helper类库依赖:

dependencies {
    api 'com.leon.channel:helper:1.1.7'
}

配置渠道列表

目前有两种方式配置渠道列表,最终的渠道列表是两者的累加之和:

  1. gradle.properties文件指定渠道文件名称,该渠道文件必须位于根工程目录下,一行一个渠道信息。
channel_file=channel.txt
  1. channel或者rebuildChannel属性中通过channelFile属性指定渠道文件,一行一个渠道信息。
channel{
    //指定渠道文件
    channelFile = file("/Users/leon/Downloads/testChannel.txt")
}
rebuildChannel{
    //指定渠道文件
    channelFile = file("/Users/leon/Downloads/testReChannel.txt")
}

通过Gradle生成多渠道包

直接编译生成多渠道包

若是直接编译生成多渠道包,首先要配置渠道文件、渠道包的输出目录和渠道包的命名规则:

channel{
    //指定渠道文件
    channelFile = file("/Users/leon/Downloads/testChannel.txt")
     //多渠道包的输出目录,默认为new File(project.buildDir,"channel")
    baseOutputDir = new File(project.buildDir,"xxx")
    //多渠道包的命名规则,默认为:${appName}-${versionName}-${versionCode}-${flavorName}-${buildType}
    apkNameFormat ='${appName}-${versionName}-${versionCode}-${flavorName}-${buildType}'
    //快速模式:生成渠道包时不进行校验(速度可以提升10倍以上)
    isFastMode = false
}

其中,多渠道包的命名规则中,可使用以下字段:

  • appName : 当前project的name
  • versionName : 当前Variant的versionName
  • versionCode : 当前Variant的versionCode
  • buildType : 当前Variant的buildType,即debug or release
  • flavorName : 当前的渠道名称
  • appId : 当前Variant的applicationId

然后,通过gradle channelDebuggradle channelRelease命令分别生成Debug和Release的多渠道包。

根据已有基础包重新生成多渠道包

若是根据已有基础包重新生成多渠道包,首先要配置渠道文件、基础包的路径和渠道包的输出目录:

rebuildChannel {
  //指定渠道文件
  channelFile = file("/Users/leon/Downloads/testReChannel.txt")
  baseDebugApk = 已有Debug APK    
  baseReleaseApk = 已有Release APK
  //默认为new File(project.buildDir, "rebuildChannel/debug")
  debugOutputDir = Debug渠道包输出目录   
  //默认为new File(project.buildDir, "rebuildChannel/release")
  releaseOutputDir = Release渠道包输出目录
  //快速模式:生成渠道包时不进行校验(速度可以提升10倍以上)
  isFastMode = false
}

然后,通过gradle rebuildChannel命令生成多渠道包。

通过命令行生成渠道包、读取渠道信息

V1.0.5版本开始支持命令行,具体使用文档可参考command目录下的README

读取渠道信息

通过helper类库中的ChannelReaderUtil类读取渠道信息。

String channel = ChannelReaderUtil.getChannel(getApplicationContext());

如果没有渠道信息,那么这里返回null,开发者需要自己判断。

Demo参考

详细的接入范式,可参考Demo

实现原理

具体原理可参考VasDolly实现原理

License

VasDolly is under the BSD license. See the LICENSE file for details.

vasdolly's People

Contributors

ltlovezh avatar zysidea avatar xingstarx avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.