Android 中的 R.class,减小 Apk 包大小
来源:互联网 发布:手机小说码字软件 编辑:程序博客网 时间:2024/06/05 09:32
ThinRPlugin
- 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 <fields>;}-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 <fields>;}-keep class **.R2 {*;}-keep class **.R2$* {*;}-keep class **.R2$*-keep class **.R2
- Android 中的 R.class,减小 Apk 包大小
- 减小APK安装包大小
- android 减小apk安装包大小方法及相关优化
- Android Develop:减小APK大小
- android apk 减小apk的大小
- 减小游戏apk安装包大小
- 减小Apk包大小的常用方法
- Android开发——减小APK大小
- Android产品研发 -->减小Apk大小
- Android开发——减小APK大小
- Android开发——减小APK大小
- Android开发之减小APK大小
- Android 减小安装包大小(二) 利用 APK Analyzer 为应用“瘦身”
- Android APK瘦身/减小包体
- 减小apk的大小
- 减小APK的大小
- Android APK 瘦身实践(减小apk的大小)
- 如何压缩减小少APK安卓安装包大小
- Dukemann聚焦:人工智能技术以及机器智能将对商业智能带来的影响
- 51Nod-1237-最大公约数之和 V3
- 使用CSS3实现树形控件
- 单页面应用程序
- java装饰模式学习记录
- Android 中的 R.class,减小 Apk 包大小
- HDU
- 网易2017春招笔试<双核处理>Java代码
- windows获取时间API
- MySQL Profiling 的使用
- SSH问题
- zcmu-1958
- 多目标优化系列(二)SMS-EMOA
- 搜狐2016招聘笔试题<发奖金>Java代码