FindIt
FindIt

Reputation: 857

How to include TypeReference ProGuard rule

I have already included following line to keep all files inside the package.

        -keep class com.fasterxml.** { *; }

I am getting following exception.

        Caused by: java.lang.IllegalArgumentException: Internal error:             TypeReference constructed without actual type information
        at com.fasterxml.jackson.core.type.TypeReference.<init>(SourceFile:36)

Upvotes: 5

Views: 1931

Answers (2)

PavelGP
PavelGP

Reputation: 1939

Also want to add my five coins. Don't use abstract class TypeReference to create an anonimous object in the code like this:

new TypeReference<YourModel>() {}

You will get IllegalArgumentException "Internal error: TypeReference constructed without actual type information" with ProGuard enabled and looks like any general rules will not help you. It is better to inherit TypeReference and create YourModelTypeReference class.

public class YourModelTypeReference extends TypeReference<YourModel> {}

Also don't forget to add proguard rule:

-keep class * extends com.fasterxml.jackson.core.type.TypeReference

Upvotes: 0

FindIt
FindIt

Reputation: 857

I found the solution. Adding the following into the ProGuard-rules or Config file solved the issue.

-keepattributes Signature

Upvotes: 13

Related Questions