Search code examples
androidgradletwilioproguard

Android proguard rule gives error with twilio client sdk


I have added the Twilio client SDK with the following proguard rules

 # Twilio Client
 -keep class com.twilio.** { *; }
 # Apache HttpClient
-dontwarn org.apache.http.**
-keepattributes InnerClasses

When that's added I get the following set of error message

Warning:library class android.webkit.WebView depends on program class android.net.http.SslCertificate
Warning:library class android.webkit.WebViewClient depends on program class android.net.http.SslError
Warning:there were 3 instances of library classes depending on program classes.
Warning:Exception while processing task java.io.IOException: Please correct the above warnings first.
Error:Execution failed for task ':app:transformClassesAndResourcesWithProguardForRelease'.
> java.io.IOException: Please correct the above warnings first.

To suppress the error I have added these set of rules

-keep public class android.net.http.SslError
-keep public class android.webkit.WebViewClient

-dontwarn android.webkit.WebView
-dontwarn android.net.http.SslError
-dontwarn android.webkit.WebViewClient

When I do the above I get these set of errors

Error:warning: Ignoring InnerClasses attribute for an anonymous inner class
Error:(android.support.design.widget.o) that doesn't come with an
Error:associated EnclosingMethod attribute. This class was probably produced by a
Error:compiler that did not target the modern .class file format. The recommended
Error:solution is to recompile the class from source, using an up-to-date compiler

which breaks the apk build. Any sort of help will be appreciated. TIA


Solution

  • Error:warning: Ignoring InnerClasses attribute for an anonymous inner class
    Error:(android.support.design.widget.o) that doesn't come with an
    Error:associated EnclosingMethod attribute. This class was probably produced by a
    Error:compiler that did not target the modern .class file format. The recommended
    Error:solution is to recompile the class from source, using an up-to-date compiler
    

    To solve innerclass issue add this in your proguard file:

    -keepattributes EnclosingMethod