{"id":14979917,"url":"https://github.com/tencent/vasdolly","last_synced_at":"2025-05-14T19:08:05.594Z","repository":{"id":40633272,"uuid":"79435860","full_name":"Tencent/VasDolly","owner":"Tencent","description":"Android V1 and V2 Signature Channel Package Plugin","archived":false,"fork":false,"pushed_at":"2023-04-07T11:07:15.000Z","size":3645,"stargazers_count":3125,"open_issues_count":21,"forks_count":392,"subscribers_count":60,"default_branch":"master","last_synced_at":"2025-05-14T19:08:00.269Z","etag":null,"topics":["android","gradle","v1","v2","vasdolly"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Tencent.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2017-01-19T09:12:31.000Z","updated_at":"2025-05-11T14:47:25.000Z","dependencies_parsed_at":"2024-01-15T02:50:46.867Z","dependency_job_id":null,"html_url":"https://github.com/Tencent/VasDolly","commit_stats":null,"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tencent%2FVasDolly","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tencent%2FVasDolly/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tencent%2FVasDolly/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tencent%2FVasDolly/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Tencent","download_url":"https://codeload.github.com/Tencent/VasDolly/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254209859,"owners_count":22032897,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","gradle","v1","v2","vasdolly"],"created_at":"2024-09-24T14:00:54.666Z","updated_at":"2025-05-14T19:08:04.067Z","avatar_url":"https://github.com/Tencent.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![license](http://img.shields.io/badge/license-BSD3-brightgreen.svg?style=flat)](https://github.com/Tencent/VasDolly/blob/master/LICENSE)\n[![Release Version](https://img.shields.io/badge/release-3.0.6-red.svg)](https://github.com/Tencent/VasDolly/releases)\n[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/Tencent/VasDolly/pulls)\n[![wiki](https://img.shields.io/badge/Wiki-open-brightgreen.svg)](https://github.com/Tencent/VasDolly/wiki)\n---\n\n\n# 简介\nVasDolly是一种快速多渠道打包工具，同时支持基于V1签名和V2,V3签名进行多渠道打包。插件本身会自动检测Apk使用的签名类别，并选择合适的多渠道打包方式，对使用者来说完全透明。\n\n目前Gradle Plugin 2.2以上默认开启V2签名，所以如果想关闭V2签名，可将下面的v2SigningEnabled设置为false。\n关于应用签名说明：[见官方文档](https://source.android.com/security/apksigning)\n``` groovy\nsigningConfigs {\n        release {\n            ...\n            v1SigningEnabled true\n            v2SigningEnabled false\n        }\n\n        debug {\n            ...\n            v1SigningEnabled true\n            v2SigningEnabled false\n        }\n    }\n```\n\n# 接入流程\n\n## 添加对VasDolly Plugin的依赖\n在根工程的`build.gradle`中，添加对打包Plugin的依赖：\n``` groovy\ndependencies {\n        classpath 'com.android.tools.build:gradle:7.0.3'\n        classpath 'com.tencent.vasdolly:plugin:3.0.6'\n}\n```\n## 引用VasDolly Plugin\n在主App工程的`build.gradle`中，添加对VasDolly Plugin的引用：\n``` groovy\napply plugin: 'com.tencent.vasdolly'\n```\n## 添加对VasDolly helper类库的依赖\n在主App工程的`build.gradle`中，添加读取渠道信息的helper类库依赖：\n``` groovy\ndependencies {\n    api 'com.tencent.vasdolly:helper:3.0.6'\n}\n```\n## 配置渠道列表\n目前有两种方式配置渠道列表，最终的渠道列表是两者的累加之和：\n1. 在`gradle.properties`文件指定渠道文件名称，该渠道文件必须位于根工程目录下，一行一个渠道信息。\n``` groovy\nchannel_file=channel.txt\n```\n2. 在`channel`或者`rebuildChannel`属性中通过`channelFile`属性指定渠道文件，一行一个渠道信息。\n``` groovy\nchannel{\n    //指定渠道文件\n    channelFile = file(\"/Users/leon/Downloads/testChannel.txt\")\n}\nrebuildChannel{\n    //指定渠道文件\n    channelFile = file(\"/Users/leon/Downloads/testReChannel.txt\")\n}\n```\n## 通过Gradle生成多渠道包\n### 直接编译生成多渠道包\n若是直接编译生成多渠道包，首先要配置渠道文件、渠道包的输出目录和渠道包的命名规则：\n``` groovy\nchannel{\n    //指定渠道文件\n    channelFile = file(\"/Users/leon/Downloads/testChannel.txt\")\n     //多渠道包的输出目录，默认为new File(project.buildDir,\"channel\")\n    outputDir = new File(project.buildDir,\"xxx\")\n    //多渠道包的命名规则，默认为：${appName}-${versionName}-${versionCode}-${flavorName}-${buildType}-${buildTime}\n    apkNameFormat ='${appName}-${versionName}-${versionCode}-${flavorName}-${buildType}'\n    //快速模式：生成渠道包时不进行校验（速度可以提升10倍以上，默认为false）\n    fastMode = false\n    //buildTime的时间格式，默认格式：yyyyMMdd-HHmmss\n    buildTimeDateFormat = 'yyyyMMdd-HH:mm:ss'\n    //低内存模式（仅针对V2签名，默认为false）：只把签名块、中央目录和EOCD读取到内存，不把最大头的内容块读取到内存，在手机上合成APK时，可以使用该模式\n    lowMemory = false\n}\n```\n其中，多渠道包的命名规则中，可使用以下字段：\n\n* appName ： 当前project的name\n* versionName ： 当前Variant的versionName\n* versionCode ： 当前Variant的versionCode\n* buildType ： 当前Variant的buildType，即debug or release\n* flavorName ： 当前的渠道名称\n* appId ： 当前Variant的applicationId\n* buildTime ： 当前编译构建日期时间，时间格式可以自定义，默认格式：yyyyMMdd-HHmmss\n\n然后，通过`gradle channelDebug`、`gradle channelRelease`命令分别生成Debug和Release的多渠道包。\n\n为了方便临时生成渠道包进行测试，我们从`v2.0.0`开始支持添加渠道参数：`gradle channelDebug(channelRelease) -Pchannels=yingyongbao,gamecenter`，这里通过属性`channels`指定的渠道列表拥有更高的优先级，且和原始的文件方式是互斥的。\n\n### 根据已有基础包重新生成多渠道包\n若是根据已有基础包重新生成多渠道包，首先要配置渠道文件、基础包的路径和渠道包的输出目录：\n``` groovy\nrebuildChannel {\n  //指定渠道文件\n  channelFile = file(\"/Users/leon/Downloads/testReChannel.txt\")\n  // 已有APK文件地址（必填）,如new File(project.rootDir, \"/baseApk/app_base.apk\"),文件名中的base将被替换为渠道名\n  baseApk = 已有APK文件地址（必填）\n  //默认为new File(project.buildDir, \"rebuildChannel\")\n  outputDir = 渠道包输出目录\n  //快速模式：生成渠道包时不进行校验（速度可以提升10倍以上，默认为false）\n  fastMode = false\n  //低内存模式（仅针对V2签名，默认为false）：只把签名块、中央目录和EOCD读取到内存，不把最大头的内容块读取到内存，在手机上合成APK时，可以使用该模式\n  lowMemory = false\n}\n```\n然后，通过`gradle rebuildChannel`命令生成多渠道包。\n\n为了方便临时生成渠道包进行测试，我们从`v2.0.0`开始支持添加渠道参数：`gradle rebuildChannel -Pchannels=yingyongbao,gamecenter`，这里通过属性`channels`指定的渠道列表拥有更高的优先级，且和原始的文件方式是互斥的。\n\n## 通过命令行生成渠道包、读取渠道信息\n从`V1.0.5`版本开始支持命令行，具体使用文档可参考`command`目录下的[README](https://github.com/Tencent/VasDolly/blob/master/command/README.md)。\n\n### 读取渠道信息\n通过helper类库中的`ChannelReaderUtil`类读取渠道信息。\n``` java\nString channel = ChannelReaderUtil.getChannel(getApplicationContext());\n```\n如果没有渠道信息，那么这里返回`null`，开发者需要自己判断。\n\n# Demo参考\n详细的接入范式，可参考[Demo](https://github.com/Tencent/VasDolly/tree/master/app)\n\n# 实现原理\n具体原理可参考[VasDolly实现原理](https://github.com/Tencent/VasDolly/wiki/VasDolly%E5%AE%9E%E7%8E%B0%E5%8E%9F%E7%90%86)\n\n# 问题反馈\n遇到任何问题或者有好的建议，欢迎提[issues](https://github.com/Tencent/VasDolly/issues)\n\n# TODO\n\n1. 增加单元测试\n2. 防渠道信息篡改\n3. 提供Python脚本\n\n# License\nVasDolly is under the BSD license. See the [LICENSE](https://github.com/Tencent/VasDolly/blob/master/LICENSE) file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftencent%2Fvasdolly","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftencent%2Fvasdolly","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftencent%2Fvasdolly/lists"}