Android Proguard - IllegalArgumentException in Jackson TypeReference class

Android app crashes if proguard is used for obfuscation. Below is the stack.

Caused by: java.lang.IllegalArgumentException: Internal error: TypeReference constructed without actual type information at abagb<init>(TypeReference.java:35) at acdq<init>(StdCouchDbInstance.java:22) at acdp<clinit>(StdCouchDbInstance.java:22) 

I use the EktorpClient library (for working with couchdb), and StdCouchDbInstance.java refers to this file and TypeReference.java to this package. Any suggestion on which option I should use in the Proguard configuration file to solve this problem?

+7
source share
2 answers

I just ran into this problem using Proguard with an Ektorp dependency. The Reference type is general, and -keepattributes Signature will contain general information.

I really used the following which solved my problem.

 -keepattributes Signature,*Annotation*,EnclosingMethod 

From Proguard Examples :

The Signature attribute is required to access generic types when compiling in JDK 5.0 and later.

+14
source

It seems that ProGuard somehow displays information about the generic type (passing type parameters). I do not know if this will be a known ProGuard problem; but you can check Jackson users mailing list if others come across this. Alternatively, you can try a different version of Jackson, although I don't think the TypeReference class has changed much.

0
source

All Articles