mar-v-in/ArtHook

Hook class method

absidibe opened this issue · 4 comments

Given this class

 public class HelloHook {
    public void sayHello(){
        Log.i("HelloHook", "SayHello");

    }
    }

In class Application

    @Hook("com.hello.HelloHook->sayHello")
    public static void HelloHook_sayHello(HelloHook call) {
        Log.d(TAG, "before Original[Activity.sayHello]");
        OriginalMethod.by(new $() {}).invoke(call);
        Log.d(TAG, "after Original[Activity.sayHello]");
    }

But it doesn't work. Have missing something or wrong usage ?

Do you call ArtHook.hook somewhere (with a reference to the application class or the method)?

Yes in Oncreate of myApplication Class I put
ArtHook.hook(CustomApplication.class);
It work well for android native method (like setText of TextView ) but with my custom class like Hellohook it does not work.

I just added a corresponding test to the test app. Can you try it out on your device running by building the test app, installing it (using ./gradlew :test:installDebug) and start it? It should display a message telling "I am god and made piece", when everything went right.

Another possible reason might be proguard minifying. You need to disable proguard minifying (at least on the methods involved with ArtHook) for it to run properly.

It work now after some updation ... thanks marv...
I will share some test case in few days