android 代码混淆问题?


android进行代码混淆时,webview用js进行交互失效了;
界面WebviewFagment在com.hello.adapter包下
js交互的类在WebviewFagment文件中定义

混淆规则
-keepattributes *Annotation*
-keepattributes *JavascriptInterface*

-dontwarn com.hello.adapter.**
-keep class com.hello.adapter.**{*;}

哪里有问题吗?

Android webview JavaScript proguard

扭曲的信仰 9 years, 7 months ago

解决了,查了很多资料,关于@JavascriptInterface被优化掉的解决办法都只提到了:
-keepattributes Annotation
-keepattributes JavascriptInterface

还要添加一句即可:
-keep class android.webkit.JavascriptInterface {*;}

倒挂的粮仓 answered 9 years, 7 months ago

Your Answer