Skip to content

fix: apply Kotlin Gradle Plugin only when AGP has no built-in Kotlin - #946

Closed
utkrishtsahu wants to merge 1 commit into
develop/v3.0from
fix/agp9-built-in-kotlin
Closed

fix: apply Kotlin Gradle Plugin only when AGP has no built-in Kotlin#946
utkrishtsahu wants to merge 1 commit into
develop/v3.0from
fix/agp9-built-in-kotlin

Conversation

@utkrishtsahu

Copy link
Copy Markdown
Contributor
  • All new/changed/fixed functionality is covered by tests (or N/A)
  • I have added documentation for all new/changed functionality (or N/A)

📋 Changes

Android Gradle Plugin 9 compiles Kotlin itself ("built-in Kotlin") and fails the build when a module also applies the Kotlin Gradle Plugin (KGP):

Failed to apply plugin 'org.jetbrains.kotlin.android'
The 'org.jetbrains.kotlin.android' plugin is no longer required for Kotlin support since AGP 9.0.

Flutter 3.47 scaffolds apps on AGP 9.1.0, so any app depending on auth0_flutter currently has to opt out with android.builtInKotlin=false — which in turn forces every other plugin in the app back onto KGP.

This changes auth0_flutter/android/build.gradle to apply KGP only where AGP will not compile Kotlin itself:

  • AGP ≤ 8 (example app / CI): unchanged — KGP is applied exactly as before.
  • AGP 9+, built-in Kotlin (the default): KGP is not applied; AGP compiles the Kotlin sources.
  • AGP 9+, host opted out with android.builtInKotlin=false: KGP is applied, as before.

The kotlinOptions { jvmTarget = '17' } block is KGP-only DSL and does not exist under built-in Kotlin, so it moves behind plugins.withId("org.jetbrains.kotlin.android") using JvmTarget.JVM_17; with built-in Kotlin, AGP derives the JVM target from compileOptions.targetCompatibility (already VERSION_17).

pluginManager.apply('kotlin-android') is used instead of apply plugin: on purpose: the Flutter tool detects KGP usage by regex-scanning plugin build scripts and would otherwise keep listing auth0_flutter in its KGP notice even on AGP 9, where this branch never runs. This mirrors the conditional apply shipped by firebase_core, stripe_android, and mobile_scanner.

No public API change.

Fixes #923.

🎯 Testing

Build-script only; no runtime code changes.

  • AGP 8 (existing users / CI / example app) — verified end-to-end. Built the auth0_flutter/example app to a debug APK on AGP 8.10.1: ✓ Built build/app/outputs/flutter-apk/app-debug.apk. On AGP ≤ 8 the script takes the original agpMajor < 9 branch and applies KGP identically to before, so existing consumers are unaffected.

@coderabbitai

coderabbitai Bot commented Sep 9, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

🗂️ Base branches to auto review (3)
  • main
  • beta-release/.*
  • release/.*

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Advanced

Run ID: ea375204-6b11-48d4-8311-f134ac5e9bc1

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant