ProGuard obfuscating classes even after `keep class` flag. Affecting Android WebView behavior

后端 未结 2 2034
青春惊慌失措
青春惊慌失措 2021-01-06 23:25

I\'m using ProGuard to obfuscate my Android app.

I\'m also using WebView to show a webpage (an HTML walkthrough page) that contains a button that will c

相关标签:
2条回答
  • 2021-01-07 00:02

    You can instruct ProGuard to keep all annotated methods:

    -keepclassmembers class * {
        @android.webkit.JavascriptInterface <methods>;
    }
    

    This should probably be part of the default configuration in the Android SDK.

    0 讨论(0)
  • 2021-01-07 00:03

    Not sure if it is just a typo in your post or not, but the ProGuard configuration file refers to

    com.myapp.android.JavaScriptInterface
    

    whereas your Java class indicates a different package

    package com.myclass.android; // myapp != myclass
    

    and, of course, they must be the same.

    EDIT: in addition to your existing configuration, try adding the following option:

    -keepclassmembers class com.myclass.android.JavaScriptInterface { 
        public <methods>;
    }
    
    0 讨论(0)
提交回复
热议问题