02-09 15:18:06.478 26166 26403 E TAG: Caused by: java.lang.NullPointerExceptionThe exception occurred only in release version, while in debug everything worked fine. So I immediately suspected that ProGuard, whose processing is part of a release build, is somehow involved here.
02-09 15:18:06.478 26166 26403 E TAG: at java.lang.Enum$1.create(Enum.java:43)
02-09 15:18:06.478 26166 26403 E TAG: at java.lang.Enum$1.create(Enum.java:35)
02-09 15:18:06.478 26166 26403 E TAG: at libcore.util.BasicLruCache.get(BasicLruCache.java:54)
02-09 15:18:06.478 26166 26403 E TAG: at java.lang.Enum.getSharedConstants(Enum.java: 209)
02-09 15:18:06.478 26166 26403 E TAG: at java.util.EnumSet.noneOf(EnumSet.java:48)
02-09 15:18:06.478 26166 26403 E TAG: at af.a(SourceFile:115)
From ProGuard's documentation:
If your application, applet, servlet, library, etc., contains enumeration classes, you'll have to preserve some special methods. Enumerations were introduced in Java 5. The java compiler translates enumerations into classes with a special structure. Notably, the classes contain implementations of some static methods that the run-time environment accesses by introspection (Isn't that just grand? Introspection is the self-modifying code of a new generation). You have to specify these explicitly, to make sure they aren't removed or obfuscated:
-keepclassmembers,allowoptimization enum * {OK, problem found: I just need to add this 'keepclassmembers' exception in ProGuard project configuration file.
public static **[] values();
public static ** valueOf(java.lang.String);
}
But what are values() and valueof(java.lang.String) needed for? I still was curious how exactly I received NullPointerException in java.lang.Enum entrails. Let's better understand it.