1

I've recently had some tasks requiring that I need to log an Android app for some events, like adding to cart, checkout, signing in to the app, pressing on a specific button, etc... to Facebook and Firebase platforms.

Since these are non-functional requirements, I figured out it could be a good idea to start implementing the AOP (Aspect Oriented Programming) method, so events can be intercepted without changing any code in the app.

I've made my research and found out that you could implement AOP using either the AspectJ lang (which is compiled to Java Bytecode and can talk to java directly), or AspectJ annotations like @Before @After and @Around to intercept the pointcuts.

However, I have read some articles like This one And This one, they don't seem to be working for me, the code before of after the pointcut calls do not get invoked at all. I feel like I might have something missing or outdated in the build.gradle aspect code that is mentioned in the first article (which is 8 years old really).

I won't be providing any code here since I've tried the exact same examples in the tutorials and didn't work for me.

I'm asking for someone recently implemented AOP in his Android app.. And could provide me with some steps that I can follow, so I can get the code in the aspects invoked and working.

Also, I've seen some people on the internet trying to implement the aspects in another Android module, and some in another src directory, if someone would explain the difference? And since I'm using Firebase and Facebook dependencies to log the events, wouldn't making the aspects in a different module affect me in any way?

Also, if anyone knows if I'm approaching the best way here to log the events (for Firebase and Facebook), or there could be better? I've went to AOP since I don't feel like changing the existing code to log some events is ideal.

Please, and thank you.

Ahmad Hamwi
  • 204
  • 2
  • 10
  • The [second article](https://jdvp.me/articles/AOP-in-Android) links to a sample project with recent changes: https://github.com/jdvp/AndroidAspectExample I would note that the correct version of plugin may be required. – Morrison Chang Feb 21 '22 at 10:24
  • @MorrisonChang Thank you for the reference. I will be trying this, and post an answer if it worked for me. – Ahmad Hamwi Feb 21 '22 at 14:50

0 Answers0