android-junit5 icon indicating copy to clipboard operation
android-junit5 copied to clipboard

Plugin is broken with AGP 8.4+

Open dant3 opened this issue 1 year ago • 5 comments

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.

dant3 avatar Aug 27 '24 13:08 dant3

Sorry, I didnt' notice 1.11 version release.

dant3 avatar Aug 27 '24 13:08 dant3

Repoen, because it doesn't work with 1.11 either

dant3 avatar Aug 27 '24 14:08 dant3

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 junitPlatform block)?

Thanks in advance.

mannodermaus avatar Aug 27 '24 23:08 mannodermaus

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") }

bddckr avatar Aug 28 '24 07:08 bddckr

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.

dant3 avatar Aug 29 '24 07:08 dant3

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.

bddckr avatar Aug 30 '24 06:08 bddckr

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!

mannodermaus avatar Oct 05 '24 00:10 mannodermaus