Change method implementation in Android with Byte Buddy

47 Views Asked by At

I want to have the implementation of some methods of Android SDK's Resources class, such as getString() use my own implementation.

I can't create my own overridden/proxy version of Resources as I get the instance from Context#getResources. I think that I need to have what Byte Buddy calls as "type rebasing" in its tutorial.

Is this possible in Android? If yes, am I supposed to use the Byte Buddy Gradle plugin for Android to achieve that?

1

There are 1 best solutions below

0
Rafael Winterhalter On

You cannot instrument classes within Android's core libraries. You can only instrument your own classes that call into Android by using MemberSubstitution.