• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

eleme/Mess: a gradle plugin for minifying activities, services, receivers, provi ...

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

eleme/Mess

开源软件地址(OpenSource Url):

https://github.com/eleme/Mess

开源编程语言(OpenSource Language):

Groovy 69.7%

开源软件介绍(OpenSource Introduction):

Mess

mess is a gradle plugin for obfuscating all code including activity, service, receiver, provider and custom view. It's really very cool to obfuscate all codes, lowers code readability after reverse engineering and ensures code's safety.

mess is super easy to integrate with your app, its implementation is also clear to understand. During android gradle assemble task execution, It has a lot of tasks to do, and can be divided to resource process & code process briefly.

process*Resources is the last task in resource process, it will generate a merged AndroidManifest.xml, aapt_rules.txt and a merged res directory in project build dir. aapt_rules.txt is the output file after aapt, it contains all classes in xml files, and then this file is delivered to proguard task as a list of keeps. transformClassesAndResourcesWithProguardFor* is the proguard task which obfuscates code, it generates a mapping.txt file which contains all mapping relation between origin and obfuscated classes.

mess hooks two android gradle tasks: process*Resources & package*, hook processResources task is to clear aapt_rules.txt, tells proguard not to obfuscate all the classes in xml; package task is the last task before package code & resource into apk, it runs after proguard, mess hooks it just to read the obfuscation mapping relation, then rewrite these into resources again, finally execute processResources task again. If your app sets shrinkResources to be true, then execute shrink task one more time.

Usage

dependencies {
   ...
   classpath 'me.ele:mess-plugin:1.1.5'
 }
  
apply plugin: 'com.android.library'
apply plugin: 'me.ele.mess'

In some cases, you want to ignore some proguard configuration provided by aar. E.g. latest Butter Knife is an aar which contains proguard.txt, so users do not need to configure its proguard manually. However, we would like to still obfuscate classes used with Butter Knife. So we provide an extension for such scenario.

mess {
    ignoreProguard 'com.jakewharton:butterknife'
}

If you are using AAPT2, please disable AAPT2 by setting android.enableAapt2=false in your gradle.properties file.

As a result, the Butter Knife's proguard configuration will be ignored. And those activities, views, fragments will be obfuscated by Mess.

That's all, just simple as that

Note

As almost every Android project uses Butter Knife for view injection. And Butter Knife has its own proguard rules which keeps every class using Butter Knife. As as result, almost every android activity, fragment, custom view would be kept. And out Mess plugin is useless.

But good news is that we studied Butter Knife source code and figured it out. And the solution is also a gradle plugin ButterMess which has been a submodule of this project.

feel free to use, welcome issue and comment




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
shemnon/javafx-gradle: Gradle JavaFX Plugin发布时间:2022-06-22
下一篇:
corda/corda-gradle-plugins: Gradle plugins used by Corda and Cordapps发布时间:2022-06-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap