How to include TypeReference ProGuard rule
Asked Answered
L

2

5

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)
London answered 10/2, 2015 at 13:48 Comment(0)
L
13

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

-keepattributes Signature
London answered 12/2, 2015 at 11:38 Comment(0)
C
0

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
Carbarn answered 21/6, 2024 at 8:39 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.