Proguard - PersistenceException: Constructor not matched for class

后端 未结 2 1049
难免孤独
难免孤独 2021-01-18 04:51

I am using retrofit2.0 in my app with simpleframework.xml library.

The problem is when I run the app without proguard it works fine however

相关标签:
2条回答
  • 2021-01-18 05:28

    I guess that your problem is that you are not keeping any attributes and that obviously depends in which attributes you are using. In my case, this is how I dealt with it, let me know if it works for you:

    ## https://square.github.io/retrofit/ ##
    -dontwarn retrofit2.**
    -keep class retrofit2.** { *; }
    -keepattributes Signature
    -keepattributes Exceptions
     -keepclasseswithmembers class * {
        @retrofit2.http.* <methods>;
    }
    
    ## Simple XML ##
    -dontwarn org.simpleframework.xml.stream.**
    -keep public class org.simpleframework.** { *; }
    -keep class org.simpleframework.xml.** { *; }
    -keep class org.simpleframework.xml.core.** { *; }
    -keep class org.simpleframework.xml.util.** { *; }
    
    -keepattributes ElementList, Root, *Annotation*
    
    -keepclassmembers class * {
        @org.simpleframework.xml.* *;
    }
    
    0 讨论(0)
  • 2021-01-18 05:37

    try adding these below lines in your proguard file. It should solve your problem

    -dontnote retrofit2.Platform
    -keepattributes Signature
    -keepattributes Exceptions
    

    and remove these below lines

    -dontwarn retrofit2.**
    -keep class retrofit2.** { *; }
    
    0 讨论(0)
提交回复
热议问题