ThinRPlugin

项目地址: mogujie/ThinRPlugin 简介:去除 Android 中的 R.class,减小 Apk 包大小
  • Other languages: [简体中文] (README.zh-cn.md) .

ThinR plugin introduce


This tool will remove all the class in R.java except the styleable class and replace the referance into the constant value. So you can reduce the dex files number and apk size.

The plugin has been used on the mogujie app, the apk size is reduced by 1MB (the original apk size of 40MB), the number of DEX reduced by 3.

ThinR plugin principle

In the R.java of android project , except the class styleable , all the class fields are int object and will never change the value in the run-time.

So in the compile-time we mark all the fields' name and their values,then use the asm tool to scan all the class files to replace the name into the value.

HOW TO USE


Add the dependency in the build.gralde of the project

 classpath   'com.mogujie.gradle:ThinRPlugin:0.0.3'

Add the following code in the inner gradle file of the module :

 apply plugin: 'thinR' thinR {     // In order not to affect the daily development of compilation speed, debug version can not delete R   skipThinRDebug = true }

If you are using Proguard, please keep the R class in the confusion file.

-keepclassmembers class **.R$* {     public static ;}-keep class **.R {*;}-keep class **.R$* {*;}-keep class **.R$*-keep class **.R

if you are using ButterKnife either, please keep the R2 class in the confusion file.

-keepclassmembers class **.R2$* {     public static ;}-keep class **.R2 {*;}-keep class **.R2$* {*;}-keep class **.R2$*-keep class **.R2

更多相关文章

  1. Android(安卓)音量增加减少按钮事件
  2. Android(安卓)改变AlertDialog的大小
  3. 修改android桌面图标默认大小
  4. 在Android上执行Java程序
  5. Android加载图片导致内存溢出(Out of Memory异常)
  6. Android中获取屏幕相关信息(屏幕大小,状态栏、标题栏高度)
  7. Android(安卓)EditText输入限制最大字符长度 和 限制只能输入数
  8. android环境部署(1.1)
  9. Android(安卓)EditText输入限制最大字符长度 和 限制只能输入数

随机推荐

  1. Android(安卓)划出一个半透明的PopupWind
  2. Android(安卓)获取几天后的时间
  3. android 4.3源码编译
  4. 关于 Linux Polkit 权限提升漏洞(CVE-202
  5. html基础-图文列表、表格
  6. html基础-表格合并练习
  7. SEO主要是做什么的?零基础能学习吗?
  8. 板绘发型怎么画?动漫绘画头发教程
  9. CF卡里面的目录无法访问也打不开文件的找
  10. 【北亚数据恢复】服务器raid阵列瘫痪导致