Skip to content

AGP 9 support: plugin crashes casting ApplicationExtension to removed legacy AppExtension #16

Description

@michelutke

Problem

Applying com.appswithlove.updraft 2.3.0 to an app module on AGP 9 (tested 9.3.1, Gradle 9.6.1) fails at configuration time:

com.android.build.gradle.internal.dsl.ApplicationExtensionImpl$AgpDecorated_Decorated
        cannot be cast to class com.android.build.gradle.AppExtension

The plugin hard-casts the android {} extension to the legacy com.android.build.gradle.AppExtension type, which AGP 9 removed. Reproduced 3× during the updraft-sdk AGP 9 migration; android.enableLegacyVariantApi=true does NOT help — it's an API-shape incompatibility, not a variant-API issue.

Fix direction

Replace the AppExtension cast with the modern DSL/AndroidComponents APIs:

  • project.extensions.getByType(com.android.build.api.dsl.ApplicationExtension::class.java) for DSL access, and/or
  • ApplicationAndroidComponentsExtension (onVariants { }) for variant-aware wiring (APK paths, variant names).

These APIs exist since AGP 7.x, so the fix can stay backwards-compatible with AGP 7/8 consumers.

Follow-up once released

⚠️ After a compatible version ships: update appswithlove/updraft-sdk — the plugin is currently parked there (commented out with a TODO(#16) marker in sample/androidApp/build.gradle.kts, see updraft-sdk PR #20 / updraft-sdk#16). Re-enabling = bump updraft in gradle/libs.versions.toml + uncomment the plugin alias, updraft {} block, and updraft_uploadUrl wiring. Until then the sample app cannot upload builds to Updraft.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions