liut

liut.xyz

Gradle Android 打包插件

Posted at — Aug 29, 2019

工作中写的一些 Gradle Task, 整理成了一个 plugin, 已发布到 Gradle 社区仓库, 源码: https://github.com/lt-123/AndroidReleasePlugin

功能说明

使用

引入

配置

Gradle Extension

在 app 模块中, 可以添加如下闭包对插件进行配置

// 不要添加在 android{} 里面
outputApk {
    /*
    输出文件名称模板, 其中,一些字符会被动态替换:

    $app: module 名称
    $b: buildType 名称
    $f: productFlavor 名称
    $vn: versionName
    $vc: versionCode
     */
    fileNameTemplate = '$app-$b-$f-$vn.$vc'

    // 输出文件夹
    outputPath = './output/'

    // 加固输出文件夹
    jiaguOutputPath = './output/jiagu/'

    // 完后后打开文件夹 此功能目前仅支持 MacOS 和 Windows, Linux 由于桌面情况复杂暂未适配
    openDir = true
}

local.properties

Android 项目的跟文件夹一般都有这个文件, 里面有Android SDK 和 NDK 路径配置。 这个文件一般不需要加到版本控制中。 如果没有此文件, 请手动创建一个。

## This file must *NOT* be checked into Version Control Systems,
# as it contains information specific to your local configuration.
#
# Location of the SDK. This is only used by Gradle.
# For customization when using a Version Control System, please read the
# header note.
#Mon Aug 19 17:43:23 CST 2019
sdk.dir=/Users/liut/Library/Android/sdk
ndk.dir=/Users/liut/Library/Android/sdk/ndk-bundle

##################################################
# 360 加固程序路径 使用加固相关功能必须配置
jiaguPath=/Users/liut/Library/jiagu/jiagu.jar
# 360 用户名 使用插件的登录登录功能必须配置
account360=您的360账户
# 360 密码 使用插件的登录登录功能必须配置
passwd360=您的360密码
# 签名 使用插件的导入签名功能需要提供, 值是app模块中的signingConfigs的名称
apkSigning=appSign
comments powered by Disqus