使用R8发行版本不排除类

问题描述

在编译应用的发行版时,我遇到了一些问题。

我当前正在使用Room,并且我的模型课位于:

com.example.room.entity

并且为了使应用正常运行,我使用了Proguard规则

-keepattributes *Annotation*,SourceFile,LineNumberTable
-keep class com.example.room.entity.**.* { *; }

构建版本并在手机上执行后,应用崩溃,并且可以看到

java.lang.classNotFoundException引起 com.roommate.example.room.entity.UserEntity

-printusage的输出显示我要保留的类被R8触及了。

我该怎么执行我的规则?

解决方法

尝试将第二行更改为:

-keep class com.roommate.example.room.entity.** { *; }