-
Notifications
You must be signed in to change notification settings - Fork 58
Instrumented tests fails when aspectj plugin is applied #93
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
The example project seems to be excluding annotation support for certain dependencies.
I tried doing the same, which didnt help
@Archinamon Could you please guide? |
What version of the gradle dist and android gradle plugin are you trying to apply it with? |
Thanks for the reply @Archinamon Output ( No tests found)
But
|
@Archinamon I have created a demo project to show the issue. https://github.com/ashj11/android-aspectj-demo. Could you please have a look and let me know what I am missing? |
Update: If i use |
@Archinamon Any update on this? Aspectj gradle plugin looked really promising for us for performance stats measurement and we would love to use it in our app. We will appreciate any help you can provide. |
I have the same issue "java.lang.ClassNotFoundException: Didn't find class ..." when trying to run instrumentation test. I will really appreciate any solution. |
I had the same issue and investigated the issue a bit deeper. Somehow aspectjrt can't be found in androidTest related classpath, so therefore the aspectj transformer does nothing with androidTest files (do not even copy them to output folders), so therefore the actual test apk contains no classes at all. It won't allow you to augment androidTest code, but tests will be executed properly. |
@rmatesz thanks for you reply. it's great to start instrumentation tests but i really need to augment androidTest code. i'm trying to create annotation which will be applied inside androidTest code. |
Thanks @rmatesz.
|
hasAjRT has been removed. You could try out the 3.4.0 version. |
We've tried the latest 3.4.3 version, and unfortunately the compilation of the instrumented tests still fails. The logs show:
And the log file contains:
It seems like the transform task actually runs now, however the weaver that is invoked fails nonetheless since the aspectjrt.jar is still not on the classpath. |
@kzsolti Could you try adding |
@kzsolti If you are using Java based aspects, then there can be an issue( #104 ). If you face this then, try using the version |
Hi, This works for me: You can change the plugin implementation depends on the gradle task executed. So in your build.gradle(app) file add this code after last 'apply plugin...': if (getGradle().getStartParameter().getTaskRequests().toString().contains("AndroidTest") || getGradle().getStartParameter().getTaskRequests().toString().contains("UnitTest")) {
apply plugin: 'com.archinamon.aspectj-junit'
aspectj {
compileTests = true
}
} else {
apply plugin: 'com.archinamon.aspectj'
aspectj {
compileTests = false
}
} |
Hi folks! Just an update if anyone is still following this thread: |
Preconditions:
Application's build.gradle has the aspectj plugin enabled
apply plugin: 'com.archinamon.aspectj'
Aspects are added to another module( library module ), with the plugin
com.archinamon.aspectj-provides
applied. This has been configured withincludeAspectsFromJar
in the app's build.gradleProblem:
When i launch Instrumentation tests my app fails to start due to:
java.lang.ClassNotFoundException: Didn't find class "com.example.MyApp" on path: DexPathList ...
Task
transformClassesWithAspectjForDebugAndroidTest
doesn't get executed correctly, thoughtransformClassesWithAspectjForDebug
prints the weaving info correctly.Note that running the application works fine( weaving works too ). Issue is only with Instrumented tests. Though #72 looks similar, it doesn't provide much insights into the solution. The issue doesn't seem to be related to Java 8.
The text was updated successfully, but these errors were encountered: