Android Proguard Javascript Interface Fail

后端 未结 4 1570
野性不改
野性不改 2020-11-28 11:51

I use in my project a piece of code as described here

http://lexandera.com/2009/01/extracting-html-from-a-webview/

I create the .apk file, install it on my d

相关标签:
4条回答
  • 2020-11-28 12:19
        -keepclassmembers class com.mypackage.MyClass$JavaScriptInterface {    
    public *;
         }
    

    Use only this. It works for me.

    0 讨论(0)
  • 2020-11-28 12:22

    Those Who are laze to provide the entire package path.

    -keepclassmembers class **.*$PaymentJavaScriptInterface{
    public *;
    }
    
    0 讨论(0)
  • 2020-11-28 12:23

    As suggested by edit in question, out of those suggestions, only using

    -keepclassmembers class com.mypackage.MyClass$MyJavaScriptInterface { public *; }

    with Important -

    For API 17+ to preserve @JavascriptInterface annotations:

    -keepattributes JavascriptInterface

    (Which was stopping my app to work on Marshmallow)

    0 讨论(0)
  • 2020-11-28 12:28

    If MyJavaScriptInterface is an inner class of MyClass, ProGuard expects a fully qualified name com.mypackage.MyClass$MyJavaScriptInterface. The naming convention with $ is used in the compiled class files on which ProGuard operates. Note that ProGuard mentions class names in the configuration that it can't find in the input jar, suggesting that these names may have been misspelled.

    0 讨论(0)
提交回复
热议问题