android - 将 SafeArgs 与 Proguard 和导航架构组件一起使用时出现 ClassNotFoundException?

标签 android proguard navigation-architecture

我正在使用 SafeArgs插件和 Navigation Architecture Component但应用程序崩溃了。

Caused by: java.lang.ClassNotFoundException: Didn't find class "com.package.domain.models.Model"
我正在使用 minifyEnabled true在 Gradle 中。
另外,我有三个模块app , data , 和 domain .所以,在所有三个 proguard-rules我添加的文件
-keepnames class com.package.domain.models.Model1
-keepnames class com.package.domain.types.ImageType
-keepnames class com.package.domain.models.Model
我将这三个类用作 argType在我的导航图中。
但是应用程序仍然崩溃。任何帮助,将不胜感激。

最佳答案

我认为更合适的做法是将这些添加到我的 proguard-rules 中。文件。

-keepnames class * extends android.os.Parcelable
-keepnames class * extends java.io.Serializable
因为我不必一直用 @Keep 注释我的模型是ParcelableSerializable或使整个模型包远离混淆。
查看this了解更多信息。

关于android - 将 SafeArgs 与 Proguard 和导航架构组件一起使用时出现 ClassNotFoundException?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67168216/

相关文章:

Android 语言翻译错误

android - 在导航架构组件中手动将 fragment 添加到后台堆栈中

android - android中的深度链接支持

android - 使用导航架构组件时在 Activity 和 Fragment 之间进行通信

java - RobolectricTestRunner,测试类只能有一个构造函数

android - 从android发送文件到其他蓝牙设备

android - Android BluetoothGatt 类中的 clientIf 字段

android - Jackson、Kotlin 和 Proguard

java - 解决许多proguard警告

android - 如何隐藏 url 请求