Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.29.0 upgrade causes early failure #1115

Closed
yschimke opened this issue Jan 27, 2024 · 3 comments
Closed

1.29.0 upgrade causes early failure #1115

yschimke opened this issue Jan 27, 2024 · 3 comments
Labels
bug Something isn't working toolchain:android
Milestone

Comments

@yschimke
Copy link

Example PR google/horologist#2009

Build scan link
N/A - I think failing during setup

Plugin version

1.29.0

Gradle version
8.5

JDK version
17

(Optional) Kotlin and Kotlin Gradle Plugin (KGP) version
1.9.21

(Optional) Android Gradle Plugin (AGP) version
8.2.2

Describe the bug

FAILURE: Build completed with 2 failures.

1: Task failed with an exception.
-----------
* What went wrong:
A problem occurred configuring project ':compose-material'.
> 
                  It is too late to add actions as the callbacks already executed.
                  Did you try to call beforeVariants or onVariants from the old variant API
                  'applicationVariants' for instance ? you should always call beforeVariants or
                  onVariants directly from the androidComponents DSL block.
                  

* Try:
> Run with --info or --debug option to get more log output.
> Get more help at https://help.gradle.org.

* Exception is:
org.gradle.api.ProjectConfigurationException: A problem occurred configuring project ':compose-material'.
	at org.gradle.configuration.project.LifecycleProjectEvaluator.wrapException(LifecycleProjectEvaluator.java:84)
	at org.gradle.configuration.project.LifecycleProjectEvaluator.addConfigurationFailure(LifecycleProjectEvaluator.java:77)
	at org.gradle.configuration.project.LifecycleProjectEvaluator.access$500(LifecycleProjectEvaluator.java:55)
...
Caused by: java.lang.RuntimeException: 
                It is too late to add actions as the callbacks already executed.
                Did you try to call beforeVariants or onVariants from the old variant API
                'applicationVariants' for instance ? you should always call beforeVariants or
                onVariants directly from the androidComponents DSL block.
                
	at com.android.build.api.extension.impl.OperationsRegistrar.addOperation(OperationsRegistrar.kt:44)
	at com.android.build.api.extension.impl.AndroidComponentsExtensionImpl.onVariants(AndroidComponentsExtensionImpl.kt:74)
	at com.android.build.api.variant.AndroidComponentsExtension.onVariants$default(AndroidComponentsExtension.kt:114)
	at com.autonomousapps.subplugin.ProjectPlugin.configureAndroidLibProject(ProjectPlugin.kt:214)
	at com.autonomousapps.subplugin.ProjectPlugin.access$configureAndroidLibProject(ProjectPlugin.kt:55)
	at com.autonomousapps.subplugin.ProjectPlugin$apply$1$1$2.execute(ProjectPlugin.kt:114)
	at com.autonomousapps.subplugin.ProjectPlugin$apply$1$1$2.execute(ProjectPlugin.kt:112)
	at org.gradle.api.internal.plugins.DefaultPluginManager$2.execute(DefaultPluginManager.java:261)
	at org.gradle.api.internal.plugins.DefaultPluginManager$2.execute(DefaultPluginManager.java:258)

To Reproduce
Steps to reproduce the behavior:

  1. run any gradle command
@yschimke
Copy link
Author

Possibly relevant - we set dependency.analysis.autoapply=false and apply separately

@gabrielittner
Copy link
Contributor

We're also seeing this on our internal project and we also disabled auto apply.

@autonomousapps autonomousapps added bug Something isn't working toolchain:android labels Feb 1, 2024
@autonomousapps autonomousapps added this to the next milestone Feb 1, 2024
@autonomousapps
Copy link
Owner

The issue does indeed go away if dependency.analysis.autoapply=false is omitted. It happens because the plugin configures itself for Android projects inside an afterEvaluate block. I think this may not be necessary. I validated that if I remove the afterEvaluate, this error doesn't occur anymore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working toolchain:android
Projects
None yet
Development

No branches or pull requests

3 participants