首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >ProGuard: ClassCastException

ProGuard: ClassCastException
EN

Stack Overflow用户
提问于 2015-05-08 10:32:03
回答 1查看 2.4K关注 0票数 2

当我混淆我的ClassCastException代码(在我使用ProGuard之前它工作得很好),我会得到这个恼人的Java。

代码语言:javascript
复制
   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错误指向这段代码,这里(粗体行是确切的行):

代码语言:javascript
复制
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声明”字段:

代码语言:javascript
复制
private final Map<String, Profile> profiles = new HashMap<String, Profile>();
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-05-09 09:13:41

你的课看上去不错。ClassCastException意味着Gson不知道一个字段应该被序列化为Profile

确保您的proguard.cfg包含所有这些规则

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/30121642

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档