}
需要hook的那个方法的类是动态载入的,就产生了这样的错误提示
Loaded app:x.x.x>>>>>>>>>>>>>
de.robv.android.xposed.XposedHelpers$ClassNotFoundError: java.lang.ClassNotFoundException: x.x.x.x.x.x.x
at de.robv.android.xposed.XposedHelpers.findClass(XposedHelpers.java:52)
at de.robv.android.xposed.XposedHelpers.findAndHookMethod(XposedHelpers.java:136)
at dev.robv.android.xposed.mods.tutorial.Tutoria.handleLoadPackage(Tutoria.java:17)
at de.robv.android.xposed.IXposedHookLoadPackage$Wrapper.handleLoadPackage(IXposedHookLoadPackage.java:20)
at de.robv.android.xposed.callbacks.XC_LoadPackage.call(XC_LoadPackage.java:34)
at de.robv.android.xposed.callbacks.XCallback.callAll(XCallback.java:70)
at de.robv.android.xposed.XposedBridge$1.beforeHookedMethod(XposedBridge.java:208)
at de.robv.android.xposed.XposedBridge.handleHookedMethod(XposedBridge.java:611)
at android.app.ActivityThread.handleBindApplication(Native Method)
at android.app.ActivityThread.access$1500(ActivityThread.java:136)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1279)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5032)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:132)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException:
x.x.x.x.x.x.x
at java.lang.Class.classForName(Native Method)
at java.lang.Class.forName(Class.java:251)
at external.org.apache.commons.lang3.ClassUtils.getClass(ClassUtils.java:823)
at de.robv.android.xposed.XposedHelpers.findClass(XposedHelpers.java:50)
... 19 more
Caused by: java.lang.NoClassDefFoundError: x.x.x.x.x.x.x
... 23 more
Caused by: java.lang.ClassNotFoundException: Didn't find class "x.x.x.x.x.x.x" on path: DexPathList[[zip file "/data/app/x.x.x.x.x.x.x-2.apk"],nativeLibraryDirectories=[/data/app-lib/x.x.x.x.x.x.x-2, /vendor/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
... 23 more
后来我将代码改为hook启动类的oncreate方法
public class Tutoria implements IXposedHookLoadPackage{
@Override
public void handleLoadPackage(LoadPackageParam lpparam) throws Throwable {
// TODO 自动生成的方法存根
if(!lpparam.packageName.equals("x.x.x"))
return;
XposedBridge.log("Loaded app:"+lpparam.packageName+">>>>>>>>>>>>>");
findAndHookMethod("x.x.x.x.LauncherUI", lpparam.classLoader, "onCreate", new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param)
throws Throwable {
// TODO 自动生成的方法存根
}
又产生了新的错误提示
Loaded app:x.x.x>>>>>>>>>>>>>
java.lang.NoSuchMethodError: x.x.x.x.Launcher#onCreate()#exact
at de.robv.android.xposed.XposedHelpers.findMethodExact(XposedHelpers.java:179)
at de.robv.android.xposed.XposedHelpers.findAndHookMethod(XposedHelpers.java:129)
at de.robv.android.xposed.XposedHelpers.findAndHookMethod(XposedHelpers.java:136)
at dev.robv.android.xposed.mods.tutorial.Tutoria.handleLoadPackage(Tutoria.java:18)
at de.robv.android.xposed.IXposedHookLoadPackage$Wrapper.handleLoadPackage(IXposedHookLoadPackage.java:20)
at de.robv.android.xposed.callbacks.XC_LoadPackage.call(XC_LoadPackage.java:34)
at de.robv.android.xposed.callbacks.XCallback.callAll(XCallback.java:70)
at de.robv.android.xposed.XposedBridge$1.beforeHookedMethod(XposedBridge.java:208)
at de.robv.android.xposed.XposedBridge.handleHookedMethod(XposedBridge.java:611)
at android.app.ActivityThread.handleBindApplication(Native Method)
at android.app.ActivityThread.access$1500(ActivityThread.java:136)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1279)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5032)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:132)
at dalvik.system.NativeStart.main(Native Method)