Skip to content

Add support for compileSdk 37 - #70

Draft
rahul-lohra wants to merge 9 commits into
developfrom
feature/rahullohra/build-on-sdk-37
Draft

Add support for compileSdk 37 #70
rahul-lohra wants to merge 9 commits into
developfrom
feature/rahullohra/build-on-sdk-37

Conversation

@rahul-lohra

Copy link
Copy Markdown

Goal

Make the convention plugins usable by consumer projects that build on Android Gradle Plugin 9.x (required for compileSdk/targetSdk = 37, Android 17), while remaining compatible with AGP 8 consumers.

Current problem

The published plugin is compiled against AGP 8.11.1, where com.android.build.api.dsl.CommonExtension is generic (CommonExtension<*, *, *, *, *, *>) and exposes block-DSL functions (compileOptions {}, testOptions {}, sourceSets {}, buildTypes {}).

In AGP 9, CommonExtension is non-generic and those block-DSL functions were removed — only the getters remain (getCompileOptions(), getTestOptions(), …). As a result, when a project on AGP 9 applies these plugins, configuration fails at runtime:

NoSuchMethodError: void com.android.build.api.dsl.CommonExtension.compileOptions(kotlin.jvm.functions.Function1)

(0.13.1's bytecode calls a method that no longer exists.) This blocks any consumer from moving to AGP 9 / compileSdk 37.

Implementation

  • Bump compile-time AGP 8.11.1 → 9.1.1 (gradle/libs.versions.toml) so the plugin compiles against the AGP-9 DSL. (compileOnly — does not force consumers onto AGP 9.)

  • BaseConfiguration.kt / coverage/CoverageConfiguration.kt — in the configureAndroid<Ext>() helpers:

    • Drop the generic args: CommonExtension<*, *, *, *, *, *>CommonExtension.
    • Replace the removed block DSLs with getter/property access:
      • compileOptions { … }compileOptions.apply { … }
      • testOptions { unitTests { … } }testOptions.unitTests.apply { … }
      • sourceSets { all { … } }sourceSets.all { … }
      • buildTypes { getByName("debug") { … } }buildTypes.getByName("debug") { … }

    This is required because member resolution inside <reified Ext : CommonExtension> binds to the upper bound (CommonExtension), so the block DSLs can't be used even though callers pass concrete ApplicationExtension/LibraryExtension/TestExtension.

  • The getters used (getCompileOptions, getTestOptions().getUnitTests(), getSourceSets(), getBuildTypes()) exist in both AGP 8 and 9, and .all {} / .getByName(name) {} only configure existing elements (safe under the ? extends variance) — so no @Suppress casts and no break for AGP 8 consumers.

Testing

  • ./gradlew :plugin:compileKotlin and publishToMavenLocal succeed.
  • Consumed from a real AGP-9.1.1 / compileSdk-37 project (stream-video-android): the prior NoSuchMethodError is gone and all modules configure and compile.

Checklist

  • Issue linked (if any)
  • Tests/docs updated
  • I have signed the Stream CLA (required for external contributors)

@rahul-lohra rahul-lohra self-assigned this Jul 27, 2026
@rahul-lohra rahul-lohra added the pr:gradle-plugins The PR includes changes to the Gradle Plugins published by this repo label Jul 27, 2026
@github-actions

Copy link
Copy Markdown
Contributor

PR checklist ✅

All required conditions are satisfied:

  • Title length is OK (or ignored by label).
  • At least one pr: label exists.
  • Sections ### Goal, ### Implementation, and ### Testing are filled, or the PR is bot-authored.
  • An issue is linked (Linear ticket or GitHub issue), or the PR is bot-authored.

🎉 Great job! This PR is ready for review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr:gradle-plugins The PR includes changes to the Gradle Plugins published by this repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant