Skip to content Skip to sidebar Skip to footer

Proguard Obfuscating Classes Even After `keep Class` Flag. Affecting Android Webview Behavior

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 close the WebView. There is a f

Solution 1:

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.

Solution 2:

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 classcom.myclass.android.JavaScriptInterface { 
    public <methods>;
}

Post a Comment for "Proguard Obfuscating Classes Even After `keep Class` Flag. Affecting Android Webview Behavior"