android-junit5
android-junit5 copied to clipboard
Plugin is broken with AGP 8.4+
When trying to build a project using this plugin and AGP 8.4.0 or newer I'm getting the following error:
* What went wrong:
Some problems were found with the configuration of task ':libraries:android-coroutine-extensions:writeFiltersDebugAndroidTest' (type 'AndroidJUnit5WriteFilters').
- Gradle detected a problem with the following location: '/Users/me/project/libraries/android-coroutine-extensions/build/generated/res/android-junit5/debugAndroidTest'.
Reason: Task ':libraries:android-coroutine-extensions:generateDebugLintReportModel' uses this output of task ':libraries:android-coroutine-extensions:writeFiltersDebugAndroidTest' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed.
Possible solutions:
1. Declare task ':libraries:android-coroutine-extensions:writeFiltersDebugAndroidTest' as an input of ':libraries:android-coroutine-extensions:generateDebugLintReportModel'.
2. Declare an explicit dependency on ':libraries:android-coroutine-extensions:writeFiltersDebugAndroidTest' from ':libraries:android-coroutine-extensions:generateDebugLintReportModel' using Task#dependsOn.
3. Declare an explicit dependency on ':libraries:android-coroutine-extensions:writeFiltersDebugAndroidTest' from ':libraries:android-coroutine-extensions:generateDebugLintReportModel' using Task#mustRunAfter.
Sorry, I didnt' notice 1.11 version release.
Repoen, because it doesn't work with 1.11 either
Thanks for reporting. Having tried AGP 8.4 and 8.5, as well as plugin 1.10 and 1.11, I can't see this with any of these combinations in my projects, so I'll need to get some more info on your setup.
- What's your Gradle version?
- What Gradle task do you execute that leads to the error posted above?
- Do you use JUnit 5 for instrumentation tests?
- If yes, do you have any test filters configured in your project (via the
junitPlatformblock)?
- If yes, do you have any test filters configured in your project (via the
Thanks in advance.
I think I've run into the same problem. It looks like the Android Lint plugin is at fault instead.
// Work around https://issuetracker.google.com/issues/337776938
tasks
.named {
it == "generateDebugAndroidTestLintModel" || it == "lintAnalyzeDebugAndroidTest"
}
.configureEach { dependsOn("writeFiltersDebugAndroidTest") }
So the details are:
- I tried different Gradle versions from 8.6 to 8.10, happens with all of them
- One more important detail is that I have a lint enabled
- I'm running
./gradlew check. Actually running any lint task causes this error. - I don't use JUnit 5 for instrumentation tests, only for unit tests
The issue is clearly caused by lint changes in AGP, the workaround posted by @bddckr really helps to overcome it. If I downgrade AGP to 8.3.2 the issue goes away as well.
AGP 8.6.0 and Android Studio Koala Feature Drop | 2024.1.2 are out. That AGP version has a fix for this issue, and the workaround I posted is no longer necessary.
Thank you for the thorough investigations, y'all! Not sure if I want to try and inject a fix for AGP 8.4 and 8.5 into the plugin itself, since I still can't seem to repro this myself. Good to know that 8.6 resolved it, though!