gpt4 book ai didi

android - 三星设备上的 Proguard "Missing type parameter"

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:08:00 25 4
gpt4 key购买 nike

我已经发布了一个安卓应用程序,被 dexguard 混淆了。一切似乎都很好,除了 Galaxy Tab 3 10.1 并且只有 Android 4.4,这是唯一向开发者控制台报告错误的设备。

我得到以下异常:

java.lang.RuntimeException: Missing type parameter.
at com.google.gson.reflect.TypeToken.<init>(:62)
at com....util.Helper$2.<init>(:398)


类 Helper.java 和第 398 行中的代码

return (Config) getSerializable(context, CONFIG, new TypeToken<Config>(){}.getType());


我的 dexguard 规则:

# For using GSON @Expose annotation
-keepattributes *Annotation*

# Gson specific classes
-keep class sun.misc.Unsafe { *; }

# Application classes that will be serialized/deserialized over Gson
# path to the config class: com/.../models/config/Config.java;
-keep class com....models.** { *; }

-keepattributes Signature


不仅我自己无法重现错误(我也有一个 Galaxy Tab 3 和 Android 4.2,更新不可用),它只涉及上述设备。

最佳答案

我的解决方案是避免使用 TypeToken 并将 dexguard 更新到最新版本。

例如:

代替

new Gson().fromJson(json, new TypeToken<Object>(){}.getType());

使用这个

new Gson().fromJson(json, Object.class);

关于android - 三星设备上的 Proguard "Missing type parameter",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26841391/

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