Android Proguard Javascript Interface Fail
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.
Proguard mess Javascript Interface functions when targeting SDK in Android Manifest above 17
I copy my answer from this topic for you: https://stackoverflow.com/a/19994873/1735499
And, if you are using Proguard, remember to add this
-keepclassmembers class * {
@android.webkit.JavascriptInterface <methods>;
}
-keepattributes JavascriptInterface
-keep public class com.mypackage.MyClass$MyJavaScriptInterface
-keep public class * implements com.mypackage.MyClass$MyJavaScriptInterface
-keepclassmembers class com.mypackage.MyClass$MyJavaScriptInterface {
<methods>;
}
If it's still not OK, add this
-keepattributes *Annotation*
Note: your MyJavaScriptInterface must be Public class
Ref#: Android Proguard Javascript Interface Fail
Br,
Frank
JavascriptInterface not working with proguard on Android 4.2
I have found the solution, I just have to tell proguard to keep the JavascriptInterface
annotation. I added this to my proguard configuration to make it work:
-keepattributes JavascriptInterface
Android Javascript Interface Fail
The problem is that proguard obfuscates the FinishExtract method.
Then the javascript can't find it because it assumes the name is still "FinishExtract"
To fix it you can change your code to:
public class JavaScriptInterface implements cmn.Proguard.KeepMembers {
Your proguard config specifies that classes which implement KeepMembers should stay unobfuscated.
Javascript interface not working with android 4.2
And, if you are using Proguard, remember to add this
-keepclassmembers class * {
@android.webkit.JavascriptInterface <methods>;
}
-keepattributes JavascriptInterface
-keep public class com.mypackage.MyClass$MyJavaScriptInterface
-keep public class * implements com.mypackage.MyClass$MyJavaScriptInterface
-keepclassmembers class com.mypackage.MyClass$MyJavaScriptInterface {
<methods>;
}
If it's still not OK, add this
-keepattributes *Annotation*
Note: your MyJavaScriptInterface must be Public class
Ref#: Android Proguard Javascript Interface Fail
Related Topics
How to Start a New Android Activity Using Class Name in a String
Preload Multiple Images with Glide
How to Check If Class Exists Somewhere in Package
Android - How to Change Fragments in the Navigation Drawer
How to Ask Permission to Access Gallery on Android M.
Libjvm.So: Cannot Open Shared Object File: No Such File or Directory
Execute Managebean Method from JavaScript Onload Event
Is a Hashmap Thread-Safe for Different Keys
How to Include the Spongy Castle Jar in Android
Efficiency of Searching Using Wherearraycontains
Listview Selection Remains Persistent After Exiting Choice Mode
How to Change Method Behaviour Through Reflection
What Does '->' (Arrow) Mean in Gradle's Dependency Graph
How to Create Button Dynamically in Android