Status Update
Comments
as...@google.com <as...@google.com> #2
enableUnitTestCoverage = false
enableAndroidTestCoverage false
Thinks started to work again.
But for what it is worth - the error message could have been more helpful.
as...@google.com <as...@google.com> #3
Well the error message is that it tried to configure jacoco task and failed, so it works for you because you disabled the feature.
So the error message is indicative of a bigger problem. Oviously, 8.2 is pretty old for us, not sure you are interested in trying 8.8.
The easiest would be to have a project reproducing the issue, if that's possible, we'll look into it.
je...@google.com <je...@google.com>
hu...@google.com <hu...@google.com> #4
Unfortunately we haven't had the resources to keep things up to date for a long time - and now every possible problem is just piling up...
I'll get back once we manage to upgrade to 8.8...
da...@jpmchase.com <da...@jpmchase.com> #5
Basically pseudo code is:
plugin {
id("com.android.library")
id("CustomPluginToConfigureAGP")
//id("org.jetbrains.kotlin.plugin.compiler")
}
If I try to do something like. checking to see if a property is set to enable Compose in either gradle properties, a custom dsl, or from an ext dsl. It fails, we successfully are able to apply Kotlin, kotlinx-serialization, etc.. All these get applied successfully.
I've tried with various ways to get applied, including doin plugin.pluginManager.withPluginId("com.android.library) {....do logic to apply compose compiler plugin }, but even that doesn't work.
In addition, I tried using the androidComponentExtension.beforeVariant, and finalizeDsl options, to apply it, but neither works.
the only way I have gotten the error to go away is to manually to uncomment the line above, and for the compiler plugin, then it works.
So not sure if AGP is doing a check for hasPlugin, or doing initialize withPlugin internally.
Wish I could provide more details, but that is basically it. I'll have to check internally if I can give a project that doesn't have any proprietary code that I can share.
hu...@google.com <hu...@google.com> #6
This is where we do isComposeCompilerPluginApplied()
is defined as
Note that this check happens in Project.afterEvaluate
, so it should be able to check the presence of applied plugins (unless for some reason a plugin is applied within Project.afterEvaluate
which may happen after this check).
If you could remove irrelevant details from your real project to create a small reproducible project, that would be great.
da...@jpmchase.com <da...@jpmchase.com> #7
The order of afterEvaluate is problematic when plugins are applying this. According to the documentation:
. Actions passed to this method execute in the same order they were passed. A parent project may add an action to its child projects to further configure those projects based on their state after their build files run.
Which means that your checks could be applied before the Plugin is replied by another plugin.
Aurimas Liutikas from the Android team working on gradle related build issues says these can can cause problems.
In general withPlugin configuration will be done once the plugin has been applied.
Again I'll try and get a small sample running, but may be some time before I get to it.
Description
Jetpack Compose component used:
Android Studio Build: AGP 8.4
Kotlin version: 2.0.21
Steps to Reproduce or Code Sample to Reproduce:
1. Set up a project for compose
2. Do not include the compiler plugin
This correctly gives the following error:
Starting in Kotlin 2.0, the Compose Compiler Gradle plugin is required
when compose is enabled. See the following link for more information:
One can solve the issue by adding the missing plugin. However, if you are using a Gradle Convention Plugin to dynamically determine when to apply the plugin, this error occurs before the plugin is applied and fails the build. It would seem that this shouldn't be a failure but a warning. Or we need a way to apply the plugin in the androidComponent Extension dsl, as the finalizeDsl step is to late.
It seems the buildFeatures.compose check is making assumptions about how the build is setup and structured and that another plugin won't supply the needed plugin before the Gradle Task Graph is ready.
Ideally there should be a way to dynamically apply the plugin from another plugin that runs after the android gradle plugin is applied.