I am trying to use Xposed on Android to hook onto an Android resource, in particular, Webview's loadUrl. The code below hooks onto loadUrl and if successful, prints a message onto the log.
findAndHookMethod("com.example.webview.MainActivity", lpparam.classLoader, "android.webkit.WebView.loadUrl", new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
XposedBridge.log("we are in loadurl!");
}
However, doing so throws an error:
java.lang.NoSuchMethodError: android.webkit.WebView#android.webkit.WebView.loadUrl()#exact
Is it even possible to hook onto Android resources with xposed?
You could use simply "hookAllMethods"
XposedBridge.hookAllMethods("com.example.webview.MainActivity", "loadUrl", new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
XposedBridge.log("we are in loadurl!");
}
It doesn't find the method because you didn't specify the method arguments. The Xposed helper function is trying to find a loadUrl method with no arguments which does not exist.
Looking at webView there are the following signatures:
I haven't tested but this should work:
try {
Method loadUrl1 = android.webkit.WebView.class.getDeclaredMethod("loadUrl", String.class);
Method loadUrl2 = android.webkit.WebView.class.getDeclaredMethod("loadUrl", String.class, Map.class);
XposedBridge.hookMethod(loadUrl1, new XC_MethodHook() { /* your code here*/});
XposedBridge.hookMethod(loadUrl2, new XC_MethodHook() { /* your code here*/});
} catch (NoSuchMethodException e) { ... }
Or even with the same API you were using:
findAndHookMethod(classname, classloader, methodName, **ARGUMENTS[]**, xc_hook)
Also, did you mean class name "android.webkit.WebView" and method "loadUrl"?
Good luck
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.