AndroidAOP icon indicating copy to clipboard operation
AndroidAOP copied to clipboard

Don't know how to get AndroidAOP to work

Open tpkarras opened this issue 1 year ago • 1 comments

Hello.

First time user of AndroidAOP.

I am trying to get AndroidAOP to work but I am unsure of how it works.

I have applied the plugin as specified with it being enabled, build log shows weaving happening.

I have tried @AndroidAOPMatchClass and @AndroidAOPReplaceClass to no avail.

I am trying to get it to output a log message when it intercepts the method.

Code is below.

import android.util.Log; import com.flyjingfish.android_aop_annotation.anno.AndroidAopReplaceClass; import com.flyjingfish.android_aop_annotation.anno.AndroidAopReplaceMethod; @AndroidAopReplaceClass( "android.app.ActivityThread" ) public class CameraSpoofer { @AndroidAopReplaceMethod( "android.app.ActivityThread currentOpPackageName()" ) public static String currentOpPackageName() { Log.d("Test", "Test"); return "different.package.name"; } @AndroidAopReplaceMethod( "android.app.ActivityThread currentPackageName()" ) public static String currentPackageName() { Log.d("Test2", "Test2"); return "different.package.name"; } }

I am on Windows 11 using Android Studio Jellyfish | 2023.3.1

What am I doing wrong?

tpkarras avatar Oct 13 '24 18:10 tpkarras

  1. First, you should experiment with the class in your package. If it works, then try to set the class in android.jar in this way.
  2. The class you set is the class in android.jar. The setting method may not appear in your apk, so it may be useless. Click here for detailed explanation

FlyJingFish avatar Oct 14 '24 01:10 FlyJingFish