JavaScriptInterface方法不可识别(Android webview)

JavaScriptInterface方法不可识别(Android webview),javascript,java,android,ajax,webview,Javascript,Java,Android,Ajax,Webview,我的主要活动包括: webView.addJavascriptInterface( new JavaScriptInterface( this ), "ajaxHandler" ); .... public class JavaScriptInterface { Context mContext; JavaScriptInterface( Context c ) { mContext = c; }

我的主要活动包括:

 webView.addJavascriptInterface( new JavaScriptInterface( this ), "ajaxHandler" );
....
 public class JavaScriptInterface
    {
        Context mContext;

        JavaScriptInterface( Context c ) {
            mContext = c;
        }

        public void DoSomething( String dataToPrint )
        {
          .....
        }
}
我读到问题可能是proguard。 因此,我更新了proguard规则文件:

-keepclassmembers class fqcn.of.javascript.interface.for.webview {
     public *;
 }

-keep public class com.example.testapp.JavaScriptInterface
-keep public class * implements com.example.testapp.JavaScriptInterface
-keepclassmembers class * implements com.example.testapp.MainActivity.JavaScriptInterface{
    public *;
}
但这没用。。。在chrome调试器中,由于我在控制台中放置了ajaxHandler对象和DoSomething方法,因此我可以将ajaxHandler对象视为
object{}
但是它是空的,并且DoSomething方法是未定义的接口类

public class JavaScriptInterface
    {
        Context mContext;

        JavaScriptInterface( Context c ) {
            mContext = c;
        }
        @JavascriptInterface //add this
        public void DoSomething( String dataToPrint )
        {
          .....
        }
}
在proGuard.pro文件中

-keep public class com.example.testapp.MainActivity$JavaScriptInterface
-keep public class * implements com.example.testapp.MainActivity$JavaScriptInterface
-keepclassmembers class * implements com.example.testapp.MainActivity$JavaScriptInterface{
     <methods>;
}
-keepattributes *Annotation*
-保留公共类com.example.testapp.MainActivity$JavaScriptInterface
-keep public class*实现com.example.testapp.MainActivity$JavaScriptInterface
-keepclassmembers类*实现com.example.testapp.MainActivity$JavaScriptInterface{
;
}
-keepattributes*注释*

使用
$
不签署
来获取内部接口类名。

谢谢,
@JavascriptInterface
注释有部分帮助-我现在可以在chrome调试器中看到该方法,但由于某种原因,我的应用程序代码中没有调用它。(javascript代码很好,因为我在iOS版本的应用程序上使用了相同的javascript代码,它在那里工作得非常完美。)已经更改了proGuard.pro文件我可以将
替换为
public*
对吗?它仍然不起作用,我可以在chrome调试器中看到该方法,但它不会在我的appinterface名称中调用,以$开头,还可以尝试#-keepattributes JavascriptInterface