gpt4 book ai didi

java - ProGuard:ClassCastException

转载 作者:行者123 更新时间:2023-11-30 08:13:07 25 4
gpt4 key购买 nike

当我混淆我的 Java 代码时(在我使用 ProGuard 混淆之前工作正常),我遇到了这个恼人的 ClassCastException

   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/Jgh4x1SSRawProfileList 类文件(未混淆):http://pastebin.com/vPxFpYfCProGuard 版本:5.2.1

配置文件声明:

private final Map<String, Profile> profiles = new HashMap<String, Profile>();

最佳答案

您的类(class)看起来不错。 ClassCastException 意味着 Gson 不知道一个字段应该被序列化为 Profile

确保您的 proguard.cfg 包含所有 these rules .

关于java - ProGuard:ClassCastException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30121642/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com