Always running proguard before Android dex'ing in Eclipse

和自甴很熟 提交于 2019-12-09 17:48:20

问题


Is there a way to make Eclipse always run proguard before dex'ing when trying to run an Android Application? e.g. some way of seamlessly inserting it as a build step?

By default it will run when exporting, but I need it to always run, even when e.g. just doing a normal "Run" or "Debug" from the menu / keyboard.


For context, the reason this is relevant is that I'm running into the "too many opcodes / no expanded opcodes" (http://code.google.com/p/android/issues/detail?id=26203) issues with my build in Eclipse. It's not an issue for ant builds because they run proguard, which strips all of the unused code. Up until now I've been manually stripping unused things from my third party dependencies, but it is getting somewhat ridiculous.

Also, as a side benefit, it should dramatically speed up my build, because a shrink-only proguard run is way, way faster than dex'ing and it removes most of the code that needs to be dex'ed.


回答1:


This behavior is hard-coded in the builder of the Eclipse plugin in the Android Development Tools. You could adapt its source code (Android Tools) so the builder behaves more like the export wizard (or internally, the BuildHelper class behaves more like the ExportHelper class). That might not be much fun to maintain though.

Alternatively, you can run Ant from Eclipse.

Also alternatively, the commercial, closed-source sibling of ProGuard, DexGuard, integrates the functionality of ProGuard and of dx (and apkbuilder, jarsign, zipalign). It can be configured to shrink/obfuscate/optimize for debug/release builds in Eclipse and in Ant.

(I am the developer of ProGuard and DexGuard)



来源:https://stackoverflow.com/questions/11320998/always-running-proguard-before-android-dexing-in-eclipse

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