All Projects → mcxiaoke → Packer Ng Plugin

mcxiaoke / Packer Ng Plugin

Licence: apache-2.0
下一代Android打包工具,100个渠道包只需要10秒钟

Programming Languages

java
68154 projects - #9 most used programming language
python
139335 projects - #7 most used programming language
groovy
2714 projects
Makefile
30231 projects
c
50402 projects - #5 most used programming language
shell
77523 projects
CMake
9771 projects

Projects that are alternatives of or similar to Packer Ng Plugin

Fastdex
🚀 加快 apk 的编译速度 🚀
Stars: ✭ 1,457 (-69.21%)
Mutual labels:  gradle, apk
Androidanimationexercise
Android 动画各种实现,包括帧动画、补间动画和属性动画的总结分享
Stars: ✭ 1,254 (-73.5%)
Mutual labels:  gradle, apk
Appaddupdate
Android app 增量更新
Stars: ✭ 192 (-95.94%)
Mutual labels:  gradle, apk
Piracychecker
An Android library that prevents your app from being pirated / cracked using Google Play Licensing (LVL), APK signature protection and more. API 14+ required.
Stars: ✭ 1,359 (-71.28%)
Mutual labels:  gradle, apk
RocketXPlugin
🔥🔥 android 端编译加速插件🚀 自动识别未改动 module 并在编译流程中替换为 aar ,只编译改动模块,加速 Android apk 的编译速度。
Stars: ✭ 408 (-91.38%)
Mutual labels:  gradle, apk
Jmh Gradle Plugin
Integrates the JMH benchmarking framework with Gradle
Stars: ✭ 441 (-90.68%)
Mutual labels:  gradle
Gradle Lint Plugin
A pluggable and configurable linter tool for identifying and reporting on patterns of misuse or deprecations in Gradle scripts.
Stars: ✭ 473 (-90%)
Mutual labels:  gradle
Markdownview Android
MarkdownView is an Android webview with the capability of loading Markdown text or file and display it as HTML, it extends Android webview.
Stars: ✭ 432 (-90.87%)
Mutual labels:  gradle
Appinfoscanner
一款适用于以HW行动/红队/渗透测试团队为场景的移动端(Android、iOS、WEB、H5、静态网站)信息收集扫描工具,可以帮助渗透测试工程师、攻击队成员、红队成员快速收集到移动端或者静态WEB站点中关键的资产信息并提供基本的信息输出,如:Title、Domain、CDN、指纹信息、状态信息等。
Stars: ✭ 424 (-91.04%)
Mutual labels:  apk
Hibernate Orm
Hibernate's core Object/Relational Mapping functionality
Stars: ✭ 4,806 (+1.56%)
Mutual labels:  gradle
Laziertracker
本项目通过Android字节码插桩插件实现Android端无埋点(或自动埋点),并且支持根据配置文件实现业务数据的自动采集。
Stars: ✭ 485 (-89.75%)
Mutual labels:  gradle
Android Tech Docs
Android官方技术文档翻译
Stars: ✭ 460 (-90.28%)
Mutual labels:  gradle
Railcraft
The Railcraft Mod for Minecraft, source and development.
Stars: ✭ 446 (-90.57%)
Mutual labels:  gradle
Android Tips Tricks
☑️ [Cheatsheet] Tips and tricks for Android Development
Stars: ✭ 4,496 (-4.99%)
Mutual labels:  gradle
Photofilter
A simple easy to use library that lets you edit pictures on the fly with easy. Photo filter lets you apply a large number of filters all while maintaining maximum image quality. Supports Android 2.3 and higher.
Stars: ✭ 434 (-90.83%)
Mutual labels:  gradle
Android Studio Poet
Generate large Android Studio projects
Stars: ✭ 489 (-89.67%)
Mutual labels:  gradle
Gradle Xcodeplugin
gradle plugin for building Xcode Projects for iOS, watchOS, macOS or tvOS
Stars: ✭ 430 (-90.91%)
Mutual labels:  gradle
Gradle Test Logger Plugin
A Gradle plugin for printing beautiful logs on the console while running tests
Stars: ✭ 460 (-90.28%)
Mutual labels:  gradle
Gradle In Action Source
Source code for the Manning book "Gradle in Action"
Stars: ✭ 483 (-89.79%)
Mutual labels:  gradle
Skript
Skript is a Bukkit plugin which allows server admins to customize their server easily, but without the hassle of programming a plugin or asking/paying someone to program a plugin for them.
Stars: ✭ 458 (-90.32%)
Mutual labels:  gradle

PackerNg V2

极速渠道打包工具

  • v2.0.1 - 2018.03.23 - 支持Android Plugin 3.x和Gradle 4.x
  • v2.0.0 - 2017.06.23 - 全新发布,支持V2签名模式,包含多项优化

特别提示

V2版只支持APK Signature Scheme v2,要求在 signingConfigsv2SigningEnabled true 启用新版签名模式,如果你需要使用旧版本,看这里 v1.0.9

项目介绍

packer-ng-plugin 是下一代Android渠道打包工具Gradle插件,支持极速打包,100个渠道包只需要10秒钟,速度是 gradle-packer-plugin300倍以上,可方便的用于CI系统集成,同时提供命令行打包脚本,渠道读取提供Python和C语言的实现。

使用指南

Maven Central

修改项目配置

// build.gradle
buildscript {
    dependencies{
        classpath 'com.mcxiaoke.packer-ng:plugin:2.0.1'
    }
}

修改模块配置

apply plugin: 'packer'
// build.gradle
dependencies {
    compile 'com.mcxiaoke.packer-ng:helper:2.0.1'
}

注意:pluginhelper 的版本号需要保持一致

插件配置示例

packer {
    archiveNameFormat = '${buildType}-v${versionName}-${channel}'
    archiveOutput = new File(project.rootProject.buildDir, "apks")
//    channelList = ['*Douban*', 'Google/', '中文/@#市场', 'Hello@World',
//                   'GradleTest', '20070601!@#$%^&*(){}:"<>?-=[];\',./']
//    channelFile = new File(project.rootDir, "markets.txt")
    channelMap = [
            "Cat" : project.rootProject.file("channels/cat.txt"),
            "Dog" : project.rootProject.file("channels/dog.txt"),
            "Fish": project.rootProject.file("channels/channels.txt")
    ]
}
  • archiveNameFormat - 指定最终输出的渠道包文件名的格式模版,详细说明见后面,默认值是 ${appPkg}-${channel}-${buildType}-v${versionName}-${versionCode} (可选)
  • archiveOutput - 指定最终输出的渠道包的存储位置,默认值是 ${project.buildDir}/archives (可选)
  • channelList - 指定渠道列表,List类型,见示例
  • channelMap - 根据productFlavor指定不同的渠道列表文件,见示例
  • channelFile - 指定渠道列表文件,File类型,见示例

注意:channelList / channelMap / channelFile 不能同时使用,根据实际情况选择一种即可,三个属性同时存在时优先级为: channelList > channelMap > channelFile ,另外,这三个属性会被命令行参数 -Pchannels 覆盖。

渠道列表格式

渠道名列表文件是纯文本文件,按行读取,每行一个渠道,行首和行尾的空白会被忽略,如果有注释,渠道名和注释之间用 # 分割。

渠道名建议尽量使用规范的中英文和数字,不要使用特殊字符和不可见字符。示例:channels.txt

集成打包

  • 项目中没有使用 productFlavors

    ./gradlew clean apkRelease
  • 项目中使用了 productFlavors

    如果项目中指定了多个 flavor ,需要指定需要打渠道包的 flavor 名字,假设你有 Paid Free 两个 flavor ,打包的时候命令如下:

    ./gradlew clean apkPaidRelease
    ./gradlew clean apkFreeRelease

    直接使用 ./gradlew clean apkRelease 会输出所有 flavor 的渠道包。

  • 通过参数直接指定渠道列表(会覆盖build.gradle中的属性):

    ./gradlew clean apkRelease -Pchannels=ch1,ch2,douban,google

    渠道数目很少时可以使用此种方式。

  • 通过参数指定渠道列表文件的位置(会覆盖build.gradle中的属性):

    ./gradlew clean apkRelease [email protected]

    使用@符号指定渠道列表文件的位置,使用相对于项目根目录的相对路径。

  • 还可以指定输出目录和文件名格式模版:

    ./gradlew clean apkRelease -Poutput=build/apks
    ./gradlew clean apkRelease -Pformat=${versionName}-${channel}

    这些参数 channels output format 可以组合使用,命令行参数会覆盖 build.gradle 对应的属性。

  • Gradle打包命令说明

    渠道打包的Task名字是 apk${flavor}${buildType} buildType一般是release,也可以是你自己指定的beta或者someOtherType,如果没有 flavor 可以忽略,使用时首字母需要大写,假设 flavorPaidrelease类型对应的任务名是 apkPaidReleasebeta类型对应的任务名是 apkPaidBetaBeta,其它的以此类推。

  • 特别提示

    如果你同时使用其它的资源压缩工具或应用加固功能,请使用命令行脚本打包增加渠道信息,增加渠道信息需要放在APK处理过程的最后一步。

脚本打包

除了使用Gradle集成以外,还可以使用项目提供的Java脚本打包,Jar位于本项目的 tools 目录,请使用最新版,以下用 packer-ng 指代 java -jar tools/packer-ng-2.0.1.jar,下面是几个示例。

  • 参数说明:
packer-ng - 表示 java -jar packer-ng-2.0.1.jar
channels.txt - 替换成你的渠道列表文件的实际路径
build/archives - 替换成你指定的渠道包的输出路径
app.apk - 替换成你要打渠道包的APK文件的实际路径
  • 直接指定渠道列表打包:
packer-ng generate --channels=ch1,ch2,ch3 --output=build/archives app.apk
  • 指定渠道列表文件打包:
packer-ng generate [email protected] --output=build/archives app.apk
  • 验证渠道信息:
packer-ng verify app.apk
  • 运行命令查看帮助
java -jar tools/packer-ng-2.0.1.jar --help
  • Python脚本读取渠道:
python tools/packer-ng-v2.py app.apk
  • C程序读取渠道:
cd tools
make
make install
packer app.apk

代码中读取渠道

// 如果没有找到渠道信息或遇到错误,默认返回的是""
// com.mcxiaoke.packer.helper.PackerNg
String channel = PackerNg.getChannel(Context)

文件名格式模版

格式模版使用Groovy字符串模版引擎,默认文件名格式是: ${appPkg}-${channel}-${buildType}-v${versionName}-${versionCode}

假如你的App包名是 com.your.company ,渠道名是 Google_PlaybuildTypereleaseversionName2.1.15versionCode200115 ,那么生成的默认APK的文件名是 com.your.company-Google_Player-release-2.1.15-20015.apk

可使用以下变量:

  • projectName - 项目名字
  • appName - App模块名字
  • appPkg - applicationId (App包名packageName)
  • channel - 打包时指定的渠道名
  • buildType - buildType (release/debug/beta等)
  • flavor - flavor (flavor名字,如paid/free等)
  • versionName - versionName (显示用的版本号)
  • versionCode - versionCode (内部版本号)
  • buildTime - buildTime (编译构建日期时间)
  • fileSHA1 - fileSHA1 (最终APK文件的SHA1哈希值)

其它说明

渠道读取C语言实现使用 GenericMakefile 构建,APK Signing Block 读取和写入Java实现修改自 apksigwalle ,特此致谢。


关于作者

联系方式

开源项目


License

Copyright 2014 - 2021 Xiaoke Zhang

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].