问题
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