Android ProGuard: Most Aggressive Optimizations

后端 未结 3 1950
醉梦人生
醉梦人生 2021-01-29 22:38

Android\'s official proguard documentation shows two primary optimizations:

  • set minifyEnabled to true
  • use proguard-androi
3条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-29 23:06

    According to the comment from the optimization file, the optimizations introduce certain risks and if used, the app must be tested thoroughly. According to my experience, it is necessary to disable code/simplification/advanced, because it caused final local variables which were initialized outside a lambda being NULL inside the lambda. It was very difficult to debug and find. Therefore my optimization settings are as follows:

    -optimizations !code/simplification/cast,!code/simplification/advanced,!field/*,!class/merging/*,!method/removal/parameter,!method/propagation/parameter

    Note that code/simplification/arithmetic must be also disabled if you target Android 2.0 and lower (which is very unlikely). Besides that, I also had to disable method/removal/parameter and method/propagation/parameter, because these implicitly enable code/simplification/advanced (see ProGuard manual for more info).

提交回复
热议问题