gpt4 book ai didi

android - 使用 GSON 时的 Proguard 问题

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

我在我的应用程序中使用 Gson,为此,我使用了一些名称与使用 Json 时相同的类。我的应用程序运行良好,但是在编写混淆器时,应用程序崩溃,我猜某些类正在缩小。我的错误是:

java.lang.ClassCastException: com.google.gson.internal.StringMap cannot be cast to com.sample.package.GsonClass

最佳答案

您需要将这些行添加到您的混淆器中,以便在签署您的应用程序时保留 gson 类。

##---------------Begin: proguard configuration for Gson  ----------
# Gson uses generic type information stored in a class file when working with fields. Proguard
# removes such information by default, so configure it to keep all of it.
-keepattributes Signature


# Gson specific classes
-keep class sun.misc.Unsafe { *; }
#-keep class com.google.gson.stream.** { *; }

# Application classes that will be serialized/deserialized over Gson
-keep class com.google.gson.examples.android.model.** { *; }

##---------------End: proguard configuration for Gson ----------

关于android - 使用 GSON 时的 Proguard 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16563916/

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