Does Proguard Converts All Enums To Int Or Needs To Be Configured For This
Solution 1:
The optimization is listed on ProGuard's optimizations page. It appears to be one of the default optimizations, but it (like other optimizations) can be specified explicitly if you need more control (e.g. disabling all class/*
optimizations aside from enum unboxing).
class/unboxing/enum
Simplifies enum types to integer constants, whenever possible.
Solution 2:
Proguard Settings
The Proguard needs to have the configuration like following:
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
Note the inclusion of the proguard-android-optimize.txt
file and not the proguard-android.txt
file.
ProguardEnumIntDefTest is a sample project on Github that tries to find out if Proguard converts enums into ints.
Optimization
For the Proguard to optimize an enum
, that enum
should not have methods and associated values(fields). Proguard converts these simple enums to ints so, you get the type-safety of the enums at compile-time and the performance of the ints at runtime!
Post a Comment for "Does Proguard Converts All Enums To Int Or Needs To Be Configured For This"