mannodermaus / android-junit5

Testing with JUnit 5 for Android.
Apache License 2.0
859 stars 53 forks source link

Plugin is broken with AGP 8.4+ #352

Open dant3 opened 2 weeks ago

dant3 commented 2 weeks ago

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 commented 2 weeks ago

Sorry, I didnt' notice 1.11 version release.

dant3 commented 2 weeks ago

Repoen, because it doesn't work with 1.11 either

mannodermaus commented 2 weeks ago

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.

Thanks in advance.

bddckr commented 2 weeks ago

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") }
dant3 commented 2 weeks ago

So the details are:

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.

bddckr commented 2 weeks ago

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.