Obsfucation + Butterknife/Databinding

风格不统一 提交于 2019-12-08 05:57:55

问题


I currently use Butterknife to inject views into my code. I noticed class names are not obsfucated when i use minifyenabled, since butterknife needs the correct class name to generate the proxy classes that will do the binding. (MainActivity.class -> MainActivity_ViewBinding.class)

I'm willing to switch to the "new" Data Binding Library in android studio. But since it's a lot of work considering my project is huge, here's my question:

  • Will the Data Binding Library also not obsfucate the classes?

  • Will switching from butterknife affect performance/size of my app?

Thanks


回答1:


Unlike Butterknife, Data Binding does not use reflection. It's all generated code. So:

  • Classes will obfuscate with Data Binding. I have found this to be true for my own apps that I switched from Butterknife.
  • Performance would likely be slightly better, but I would not expect much of a gain. I have not benchmarked it.
  • The Data Binding libraries don't seem to pull in any other libraries, so size-wise, there should not be a concern; don't remember what dependencies Butterknife has, my guess is there are some. The Data Binding libraries add about 60 classes themselves, most of which you won't actually use. Using Proguard (or the Android Shrinker) to eliminate unused classes and methods will minimize this impact as well; not sure how many classes & methods the Butterknife libraries bring in. In addition there are classes generated from your code with both approaches, but their impact on size should not be that significant.


来源:https://stackoverflow.com/questions/44050385/obsfucation-butterknife-databinding

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!