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

AGP 8.4.1 gives issue due to usage of deprecated API

Open bddckr opened this issue 1 year ago • 1 comments

The issue has already been reported to the AGP maintainers here. However, I wonder whether there's a replacement API that isn't deprecated that this project could use to work around the problem. https://github.com/mannodermaus/android-junit5/blob/38ef72c06afe2dc23e94bf7d32cff5a41992b52c/plugin/android-junit5/src/main/kotlin/de/mannodermaus/gradle/plugins/junit5/tasks/AndroidJUnit5WriteFilters.kt#L51-L53

I believe the latest API to do the same is one of the following.

androidComponents.onVariants { variant ->
    variant.sources.res?.let { res -> res.addGeneratedSourceDirectory(...) }
}

There's also addStaticSourceDirectory, but since the output of a task is needed here, addGeneratedSourceDirectory is probably the right one.

An example can be found here. The Readme for that example project is in the root folder.


I've applied the following workaround in my project for now:

tasks
    .named {
        it == "generateDebugAndroidTestLintModel" || it == "lintAnalyzeDebugAndroidTest"
    }
    .configureEach { dependsOn("writeFiltersDebugAndroidTest") }

bddckr avatar May 22 '24 05:05 bddckr

Hey, thanks for reporting. We've been getting away with the old Variant API for many years now, but I guess all things must come to an end eventually. Since the next plugin version raises the minimum AGP requirement to 8.0, we finally have access to the new Variant API for source directories throughout all of the supported versions, so I'm okay with swapping out the implementation

mannodermaus avatar May 22 '24 14:05 mannodermaus

Released in plugin 1.10.2.0!

mannodermaus avatar Jul 25 '24 13:07 mannodermaus