rahul_lohra
07/23/2020, 4:45 AMjava agent
in Android, basically there is a premain function
and I need this function to run before the Android's main function bus I was unsuccessful. So I am looking for some advice, what can go wrong? Also I am not getting anything on the log cat so it very difficult to debug
The is the manifest
of the jar
Manifest-Version: 1.0
Premain-Class: com.rahullohra.myagent.MyPremain
Launcher-Agent-Class: com.rahullohra.myagent.MyPremain
Boot-Class-Path: /home/rahulkumarlohra-xps/AndroidStudioProjects/Lab/m
yagent/build/libs/myagent.jar
In gradle.properties
I have passed this jar as
org.gradle.jvmargs=-javaagent:'/home/rahulkumarlohra-xps/AndroidStudioProjects/Lab/myagent/build/libs/myagent.jar'
Adam Powell
07/23/2020, 1:32 PMrahul_lohra
07/23/2020, 4:14 PMDEBUG
variant
TL;DR - I want to inject bytecode/java code some classes during compile time at specific places. I do not want to use any annotations.
Full story:
What I want & Why: -
Two things
First -
I want to track our image loading performance in our app. Now assume my team is using Glide to load images and lot of people have already written code like below
Glide.with(context).load(url).into(imageView)
Now during compile time I want to attach listener
to above code and it will now look like this -
val glideListener = {....some logic...}
Glide.with(context).load(url).addListener(glideListener).into(imageView)
Now I know anyone will say that one should use a common class to load images, so that all the image loading calls will go through there and I totally agree with this. But I just want to explore what are the other possible ways to achieve this thing
Second thing -
I want to avoid exceptions.
So I want to execute some instructions just before my actual content function will start to execute (This is very similar to aspectJ)Adam Powell
07/23/2020, 5:17 PMrahul_lohra
07/23/2020, 7:23 PMJustin Tullgren
07/24/2020, 3:58 PMrahul_lohra
07/27/2020, 5:45 AM