For the last few days I am struggling with instrumenting my Salesforce-based Android application using aspectj. Due to the fact that I assumed something is wrong with my changes, I downloaded pure Salesforce example from https://github.com/forcedotcom/SalesforceMobileSDK-Android and the result was the same.
;TLDR;
The library used for instrumentation uses aspectj and it is definitely working correctly since I used it for many other applications before without any problem. What I normally do to make it work is add the following lines to the project's build.gradle:
buildcsript {
...
dependencies {
classpath 'com.uphyca.gradle:gradle-android-aspectj-plugin:0.9.14'
...
}
...
}
And below ones to app's build.gradle file:
apply plugin: 'android-aspectj'
...
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
....
}
....
Unfortunately, this approach doesn't work with the sample Salesforce application - the build process is successful but my library is not in the final output. The only indicator of the problem is the following warning displayed during compilation:
advice defined in xxx.OnCreate has not been applied [Xlint:adviceDidNotMatch]
During my investigations I found out this https://stackoverflow.com/a/6267151 entry. I tried to run a script I have which instruments small apk with my library using those additional arguments:
-Xset:weaveJavaxPackages=true -Xset:weaveJavaPackages=true
and it actually worked and resulted in an instrumented application. Unfortunately, I cannot do it with my original application since it is a multi-dex one and I need to add the library to it with a use of Android Studio. After this long introduction this is where my actual question begins:
;TLDR;
Is it possible to add weaver arguments [weaveJavaxPackages and weaveJavaPackages] to the aspectj plugin from within Android Studio?
I already tried manually adding an aop.xml file to my app's src/main/resources/META-INF path which was suggested to me as a default one for aspect properties - it didn't work. It looked like the file was ignored completely.
I also tried to change the aspectj plugin to https://github.com/HujiangTechnology/gradle_plugin_android_aspectjx but I also did not find how to add weaving arguments there.
Any other suggestion, advice, help will be highly apprieciated. Thanks a lot, guys!