Skip to content Skip to sidebar Skip to footer

Intercepting Third Party Functions In Android Using Aspectj

I have been trying to intercept all the third party functions which are part of my application using aspectJ, but somehow am only able to intercept the functions declared by me and

Solution 1:

To paraphrase another answer that has been given multiple times :

You can only weave your own code

Basically Aspects with android only works at compile time and will usually weave your own code. If you're using existing code for which you don't have source (like the Android framework for example), the compiler won't have access to modify those. In your case, you can only catch when your code is accessing the third party library.

Meaning that if you want to intercept third party libraries you need to use "call(* *(..))" instead of "execution(* *(..))"

Solution 2:

You can weave third party libraries' code with my gradle-aspectj plugin. It's possible because of Transform API, which handles all project sources, not only src/* packages, but jars/aars, sub-modules too. But beware using weaving of third party code, it may lead to unexpected behaviours.

Post a Comment for "Intercepting Third Party Functions In Android Using Aspectj"