Closed sheelaknaik closed 6 years ago
https://github.com/sheelaknaik/AspectJ
Sample project uploaded on above github
In your app module gradle file you need to specify that you want to include aspects from elsewhere.
Try adding the following to the file under the dependencies section:
aspectj { includeAspectsFromJar 'Seclib' }
Thanks for you response. I have tried this and it doesn't seem to be working. Would you please try to run the attached sample and see how we can support aar ?
I had tried this. I verified that these pointcuts
Full ajc build args: -encoding, UTF-8, -source, 1.7, -target, 1.7, -d, /Users/jdvp/Downloads/AspectJ-master/TestFinalwithLibrary/app/build/intermediates/transforms/aspectj/debug/0, -bootclasspath, /Users/jdvp/Library/Android/sdk/platforms/android-26/android.jar, -classpath, /Users/jdvp/.gradle/caches/modules-2/files-2.1/org.aspectj/aspectjrt/1.8.10/1a14fe9e912f6e8bdbb5429b78b4090d8b47bc1/aspectjrt-1.8.10.jar:/Users/jdvp/.gradle/caches/transforms-1/files-1.1/design-26.1.0.aar/229c99ce44a9c2cf769de0f4de3a7bbf/jars/classes.jar:/Users/jdvp/.gradle/caches/transforms-1/files-1.1/appcompat-v7-26.1.0.aar/1e90df4e0b04f0ded49a81f1e54de7ac/jars/classes.jar:/Users/jdvp/.gradle/caches/transforms-1/files-1.1/constraint-layout-1.1.0.aar/ad0c87dfae6b9cc9b35556034e8f4a00/jars/classes.jar:/Users/jdvp/.gradle/caches/transforms-1/files-1.1/animated-vector-drawable-26.1.0.aar/01b80e0bd4a32934b76ba53b72eb93e8/jars/classes.jar:/Users/jdvp/.gradle/caches/transforms-1/files-1.1/support-vector-drawable-26.1.0.aar/2d83e23ca0bf9ccd4acbd84c43e55e25/jars/classes.jar:/Users/jdvp/.gradle/caches/transforms-1/files-1.1/recyclerview-v7-26.1.0.aar/eaebc5f3ff387e5c55cd55c3bad3f9ba/jars/classes.jar:/Users/jdvp/.gradle/caches/transforms-1/files-1.1/transition-26.1.0.aar/8b9798039d8d6dee7bd3b052d1563be7/jars/classes.jar:/Users/jdvp/.gradle/caches/transforms-1/files-1.1/support-v4-26.1.0.aar/7ca0a6b8716c5f39bcec40ee4409cd4a/jars/classes.jar:/Users/jdvp/.gradle/caches/transforms-1/files-1.1/support-media-compat-26.1.0.aar/0e544c09b08ae23c5b575e9b64cf5e5d/jars/classes.jar:/Users/jdvp/.gradle/caches/transforms-1/files-1.1/support-fragment-26.1.0.aar/0b09dd678edf27f482cb3cf8510d5454/jars/classes.jar:/Users/jdvp/.gradle/caches/transforms-1/files-1.1/support-core-utils-26.1.0.aar/31dc0673c65cf7266bc8164a78b52f68/jars/classes.jar:/Users/jdvp/.gradle/caches/transforms-1/files-1.1/support-core-ui-26.1.0.aar/82afdef18a648596994432d536363e45/jars/classes.jar:/Users/jdvp/.gradle/caches/transforms-1/files-1.1/support-compat-26.1.0.aar/bc3e29326d51a52f51b7506d2d3f4327/jars/classes.jar:/Users/jdvp/.gradle/caches/modules-2/files-2.1/com.android.support/support-annotations/26.1.0/814258103cf26a15fcc26ecce35f5b7d24b73f8/support-annotations-26.1.0.jar:/Users/jdvp/.gradle/caches/modules-2/files-2.1/com.android.support.constraint/constraint-layout-solver/1.1.0/931532e953a477f876f2de18c2e7f16eee01078f/constraint-layout-solver-1.1.0.jar:/Users/jdvp/.gradle/caches/transforms-1/files-1.1/runtime-1.0.0.aar/1aaad834d23ba10e9995a7b7ca1e30db/jars/classes.jar:/Users/jdvp/.gradle/caches/modules-2/files-2.1/android.arch.lifecycle/common/1.0.0/e414a4cb28434e25c4f6aa71426eb20cf4874ae9/common-1.0.0.jar:/Users/jdvp/.gradle/caches/modules-2/files-2.1/android.arch.core/common/1.0.0/a2d487452376193fc8c103dd2b9bd5f2b1b44563/common-1.0.0.jar:/Users/jdvp/.gradle/caches/transforms-1/files-1.1/Seclib-debug-2.5.aar/ab9ddccb5740b339b77f68d37daabaac/jars/classes.jar:/Users/jdvp/Downloads/AspectJ-master/TestFinalwithLibrary/app/build/intermediates/classes/debug, -inpath, /Users/jdvp/Downloads/AspectJ-master/TestFinalwithLibrary/app/build/intermediates/classes/debug, -aspectpath, /Users/jdvp/.gradle/caches/transforms-1/files-1.1/Seclib-debug-2.5.aar/ab9ddccb5740b339b77f68d37daabaac/jars/classes.jar, -log, /Users/jdvp/Downloads/AspectJ-master/TestFinalwithLibrary/app/build/ajc-transform.log, -showWeaveInfo
Tue Jul 03 17:15:20 EDT 2018
Join point 'method-execution(void com.aspectj.root.testfinal.MainActivity$1.onClick(android.view.View))' in Type 'com.aspectj.root.testfinal.MainActivity$1' (MainActivity.java:25) advised by before advice from 'com.vodafone.lib.seclibng.MetricsAspect' (classes.jar!MetricsAspect.class(from MetricsAspect.java))
Join point 'method-execution(void com.aspectj.root.testfinal.MainActivity$1.onClick(android.view.View))' in Type 'com.aspectj.root.testfinal.MainActivity$1' (MainActivity.java:25) advised by afterThrowing advice from 'com.vodafone.lib.seclibng.ExceptionHandler' (classes.jar!ExceptionHandler.class(from ExceptionHandler.java))
Join point 'method-execution(void com.aspectj.root.testfinal.MainActivity.onCreate(android.os.Bundle))' in Type 'com.aspectj.root.testfinal.MainActivity' (MainActivity.java:16) advised by afterThrowing advice from 'com.vodafone.lib.seclibng.ExceptionHandler' (classes.jar!ExceptionHandler.class(from ExceptionHandler.java))
Join point 'method-execution(boolean com.aspectj.root.testfinal.MainActivity.onCreateOptionsMenu(android.view.Menu))' in Type 'com.aspectj.root.testfinal.MainActivity' (MainActivity.java:34) advised by afterThrowing advice from 'com.vodafone.lib.seclibng.ExceptionHandler' (classes.jar!ExceptionHandler.class(from ExceptionHandler.java))
Join point 'method-execution(boolean com.aspectj.root.testfinal.MainActivity.onOptionsItemSelected(android.view.MenuItem))' in Type 'com.aspectj.root.testfinal.MainActivity' (MainActivity.java:43) advised by before advice from 'com.vodafone.lib.seclibng.MetricsAspect' (classes.jar!MetricsAspect.class(from MetricsAspect.java))
Join point 'method-execution(boolean com.aspectj.root.testfinal.MainActivity.onOptionsItemSelected(android.view.MenuItem))' in Type 'com.aspectj.root.testfinal.MainActivity' (MainActivity.java:43) advised by afterThrowing advice from 'com.vodafone.lib.seclibng.ExceptionHandler' (classes.jar!ExceptionHandler.class(from ExceptionHandler.java))
/Users/jdvp/.gradle/caches/transforms-1/files-1.1/Seclib-debug-2.5.aar/ab9ddccb5740b339b77f68d37daabaac/jars/classes.jar!com/vodafone/lib/seclibng/MetricsAspect.class [warning] advice defined in com.vodafone.lib.seclibng.MetricsAspect has not been applied [Xlint:adviceDidNotMatch]
had been added when using
aspectj {
includeAllJars true
includeJar 'Seclib'
includeAspectsFromJar 'Seclib'
}
in the app level build.gradle. Here is the full build.gradle for reference:
apply plugin: 'com.android.application'
apply plugin: 'com.archinamon.aspectj'
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.aspectj.root.testfinal"
minSdkVersion 19
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
implementation 'com.android.support:design:26.1.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
implementation project(':Seclib-debug-2.5')
}
aspectj {
includeAllJars true
includeJar 'Seclib'
includeAspectsFromJar 'Seclib'
}
Hope this helps @sheelaknaik
Hi @jdvp, Thanks for your response.
I see that with the mentioned changes, aar is working perfectly.
includeJar 'Seclib'
The above line was something I was missing.
Thanks once again :)
Hi @jdvp. We can modify aspectj only on Seclib Module , no need to modify but we can track UI ? If we can do that, please tell me how?
Hi There,
I'm using this plug-in to track UI clicks and Page lifecycle events as part of library which I'm implementing.
However, if I directly include the library code in any sample application, it is able to capture all events. But when converted to aar file and then merged in the sample app, it does not identify UI clicks(only Page events are identified).
Is there any such limitation with building this plugin as a library(aar)? Please help as this is crucial in my project.
Thank you in advance.
Regards, Sheela