登录

去注册 忘记密码?

登录

注册

去登录

  • 扫码关注公众号
  • 发送“我爱安卓
  • 即可获取验证码

注册

解锁回答区域

  • 扫码关注公众号
  • 发送“我爱安卓

若你登陆,将永久解锁;
若未登录,仅本机解锁。

解锁回答区域

获取注册验证码

  • 扫码关注公众号
  • 发送“我爱安卓
  • 即可获取验证码

ScratchPaper - 为 icon 和 apk 添加 build info 的 Gradle Plugin 支持 AAPT2 和 Instant Run

2BAB   2018-09-21 18:24   收藏

ScratchPaper (v2.x)

JCenter Apache 2 Welcome PRs

[中文说明][English]

ScratchPaper 都做了些什么?

如果你在一台设备上安装两个 App,一个是 Debug 版一个是 Release 版,那么你很难区分出来到底哪个是哪个(不打开的情况下)。

ScatchPaper 可以在你的 App icon 上加一个蒙层用以区分出各个 BuildType 的 App,并且承载了版本信息等附加文字。

如果你同时打了多个测试包给测试或者产品(例如基于多个复合分支),当他们给你反馈的问题时候你和他们可能都很难分别出每个 App 对应的具体的分支或者 commit 节点。

ScatchPaper 支持生成编译信息并打包到你的 Apk 中(从 assets 中读取),以及输出一份拷贝到 /intermedias/scratch-paper/assets 文件夹,包括:

  • Base: Build Time, Build Type, etc.
  • Git: Latest Commit ID & commit branch, etc.
  • Dependencies
  • ...

如何使用?

0x01. Add the plugin to classpath:

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.4'
        classpath 'me.2bab:scratch-paper:2.1.1'
    }
}

0x02. Apply Plugin:

// On Application's build.gradle (do not use in Library project)
apply plugin: 'me.2bab.scratchpaper'

0x03. Build your App and Enjoy!

0x04. Advanced Configurations

scratchPaper {
    textSize = 12
    textColor = "#FFFFFFFF"
    verticalLinePadding = 4
    backgroundColor = "#99000000"
    extraInfo = "This is a sample!"
    enableGenerateIconOverlay = true
    enableGenerateBuildInfo = true
    
    // Experimental field
    // @see IconOverlayGenerator#removeXmlIconFiles
    enableXmlIconRemove = false
}

兼容性

ScratchPaper 只会支持最新两个 Minor 版本的 Android Gradle Plugin:

AGP VersionCompatible Status
3.1.x (Aapt2)Support
3.0.x (Aapt2)Support
2.3.x (Aapt2)Never Tested
2.3.x (Aapt1)Not Support

v1.x (Deprecated)

The v1.x IconCover forked from icon-version@akonior. It provided icon editor functions that compatible with Aapt1, and I added some little enhancement like hex color support, custom text support. As time goes by, we have to move to Aapt2 sooner or later. So I decide to revamp the whole project and add more fancy features. If you are still using Aapt1 with IconCover, now is the time to consider moving into the new one.

License

Copyright 2018 2BAB

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.

项目地址:https://github.com/2BAB/ScratchPaper