java - ProGuard: ClassCastException -


i'm getting annoying classcastexception when obfuscate java code (which works fine before obfuscate using proguard).

   java.lang.classcastexception: com.google.gson.internal.stringmap cannot cast net.minecraft.launcher.profile.profile         @ java.lang.classcastexception: com.google.gson.internal.stringmap cannot cast net.minecraft.launcher.profile.profile @ net.minecraft.launcher.profile.profilemanager.getselectedprofile(sourcefile:117) @ net.minecraft.launcher.g.run(sourcefile:184) @ java.util.concurrent.executors$runnableadapter.call(unknown source) @ java.util.concurrent.futuretask.run(unknown source) @ java.util.concurrent.threadpoolexecutor.runworker(unknown source) @ java.util.concurrent.threadpoolexecutor$worker.run(unknown source) @ java.lang.thread.run(unknown source) 

that clastcastexception error points bit of code, here (the bolded line being exact line):

public profile getselectedprofile() {     if ((this.selectedprofile == null) || (!this.profiles.containskey(this.selectedprofile))) {         if (this.profiles.get("default") != null)         {             this.selectedprofile = "default";         }         else if (this.profiles.size() > 0)         {             this.selectedprofile = ((profile)this.profiles.values().iterator().next()).getname();         }         else         {             this.selectedprofile = "default";             this.profiles.put("default", new profile(this.selectedprofile));         }     }     *profile profile = this.profiles.get(this.selectedprofile);*     return profile; } 

whole class file (un obfuscated) : http://pastebin.com/jgh4x1ss rawprofilelist class file (un obfuscated) : http://pastebin.com/vpxfpyfc proguard version : 5.2.1

declaration of profiles field:

private final map<string, profile> profiles = new hashmap<string, profile>(); 

your classes fine. classcastexception means gson didn't know field should have been serialized profile.

make sure proguard.cfg contains of these rules.


Comments