Search code examples
javaandroidkotlinproguard

Unknown class specified for dataClass - ProGuard


I need some help, i've activated the proguard for code obfuscation but when i launch the app, crash and logcat print this:

java.lang.RuntimeException: Unable to create application eu.reply.lea.mobile.core.showcase.ShowcaseApplication: java.lang.IllegalArgumentException: Unknown class specified for dataClass: eu.reply.lea.mobile.core.oldies.entity.User

...

Caused by: java.lang.IllegalArgumentException: Unknown class specified for dataClass: eu.reply.lea.mobile.core.oldies.entity.User

In the proguard file i added this lines but doesn't change nothing.

-keepclassmembernames class eu.reply.lea.mobile.core.oldies.entity.User {
    public *;
}

-keepclassmembernames class eu.reply.lea.mobile.core.showcase.ShowcaseApplication {
    public *;
}

Tried to add @keep and @keepnames annotations in user but nothing changed.

How can i solve this?

Thank you all!


Solution

  • The reason why these errors are showing up can have 2 causes:

    1. This class has been removed because of shrinking
    2. This class relies on reflection

    I would suggest adding the following keeprule to your proguard configuration file:

    -keep class eu.reply.lea.mobile.core.oldies.entity.User
    

    A useful tool you can use to check what parts of your code will be affected when you define this keeprule can be found here.