gradle-play-publisher: [AGP 4.2.0-alpha12]: AnalyticsEnabledApplicationVariantBuilder_Decorated cannot be cast to class ApplicationVariant

Describe the bug

Plugin doesn’t currently work with AGP 4.2.0-alpha12

Caused by: java.lang.ClassCastException: class com.android.build.api.component.analytics.AnalyticsEnabledApplicationVariantBuilder_Decorated cannot be cast to class com.android.build.api.variant.ApplicationVariant (com.android.build.api.component.analytics.AnalyticsEnabledApplicationVariantBuilder_Decorated and com.android.build.api.variant.ApplicationVariant are in unnamed module of loader org.gradle.internal.classloader.VisitableURLClassLoader @6e5b0de3)
        at com.github.triplet.gradle.play.PlayPublisherPlugin$applyInternal$2.invoke(PlayPublisherPlugin.kt:59)
        at com.android.build.gradle.internal.dsl.CommonExtensionImpl$onVariants$1.execute(CommonExtensionImpl.kt:230)
        at com.android.build.gradle.internal.dsl.CommonExtensionImpl$onVariants$1.execute(CommonExtensionImpl.kt:40)
        at com.android.build.api.variant.impl.VariantOperations.executeActions(VariantOperations.kt:61)
        at com.android.build.gradle.internal.dsl.CommonExtensionImpl.executeVariantOperations(CommonExtensionImpl.kt:242)
        at com.android.build.gradle.internal.dsl.BaseAppModuleExtension.executeVariantOperations(BaseAppModuleExtension.kt)
        at com.android.build.gradle.internal.dsl.BaseAppModuleExtension.executeVariantOperations(BaseAppModuleExtension.kt:37)
        at com.android.build.gradle.internal.VariantManager.createVariant(VariantManager.java:370)
        at com.android.build.gradle.internal.VariantManager.createVariantsFromCombination(VariantManager.java:847)
        at com.android.build.gradle.internal.VariantManager.computeVariants(VariantManager.java:270)
        at com.android.build.gradle.internal.VariantManager.createVariants(VariantManager.java:215)
        at com.android.build.gradle.internal.plugins.BasePlugin.createAndroidTasks(BasePlugin.java:654)
        at com.android.builder.profile.ThreadRecorder.record(ThreadRecorder.java:69)
        ... 159 more

Versions

  • Gradle Play Publisher: 3.0.0
  • Gradle Wrapper: 6.6.1
  • Android Gradle Plugin: 4.2.0-alpha12

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 19
  • Comments: 18 (3 by maintainers)

Commits related to this issue

Most upvoted comments

Just confirming, 3.2.0-SNAPSHOT works for me. Thanks Alex! 🙌

Nah, still haven’t figured out the ordering. That said, I’d like to unblock people so I released an unofficial 3.2.0 snapshot. It’s compatible with alpha12 and alpha13.

@SUPERCILEX apologies for the problems you’re having. These kinds of breakages are exactly why the AGP team are working on a stable API right now. And even though they are doing everything they can to maintain binary and source compatibility with previous plugins, it’s not always possible and unfortunately some of the new APIs that have been added in 4.1/4.2 canaries are still incubating, which means they have and will change while they iterate on them.

For instance, onVariant/onVariantProperties (and maybe some of the underlying types) are being rewritten right now, so… sorry about that, but it’s for the best. We’re aiming to have these stable in 4.2+1 version, whatever it will be (4.3, 5.0, who knows).

If I find some time I’ll take a look at the issue you’re seeing, but I don’t currently have a checkout of your project handy, so it might take me a while until I get to it.

Thanks for doing this @SUPERCILEX, very appreciated!