0

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!

Community
  • 1
  • 1
  • You can add weaving arguments with this plugin : https://github.com/deezer/Android-Aspectj-Plugin It's a fork of uphyca's plugin but in the read me it shows how to add extra AspectJ Flags – XGouchet Aug 30 '16 at 20:12
  • You may try [my plugin](https://github.com/Archinamon/GradleAspectJ-Android) for Android. Custom arguments, transform api, handling .aj and annotation style aspects. – Archinamon Oct 31 '16 at 22:11

0 Answers0