当我混淆我的ClassCastException代码(在我使用ProGuard之前它工作得很好),我会得到这个恼人的Java。
java.lang.ClassCastException: com.google.gson.internal.StringMap cannot be cast to net.minecraft.launcher.profile.Profile
at java.lang.ClassCastException: com.google.gson.internal.StringMap cannot be cast to net.minecraft.launcher.profile.Profile
at net.minecraft.launcher.profile.ProfileManager.getSelectedProfile(SourceFile:117)
at net.minecraft.launcher.g.run(SourceFile:184)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)这个ClastCastException错误指向这段代码,这里(粗体行是确切的行):
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;
}整类文件(未混淆):http://pastebin.com/Jgh4x1SS RawProfileList类文件(未混淆):http://pastebin.com/vPxFpYfC ProGuard版本: 5.2.1
“Profiles声明”字段:
private final Map<String, Profile> profiles = new HashMap<String, Profile>();发布于 2015-05-09 09:13:41
你的课看上去不错。ClassCastException意味着Gson不知道一个字段应该被序列化为Profile。
确保您的proguard.cfg包含所有这些规则。
https://stackoverflow.com/questions/30121642
复制相似问题