Skip to content

feat(android): migrate plugins to built-in Kotlin on Flutter 3.44 - #18922

Merged
SelaseKay merged 4 commits into
mainfrom
chore/flutter-3.47-sdk-floor
Nov 13, 2026
Merged

SelaseKay merged 4 commits into
mainfrom
chore/flutter-3.47-sdk-floor

Conversation

@SelaseKay

@SelaseKay SelaseKay commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Description

Migrates the Android plugins that apply the Kotlin Gradle Plugin onto AGP built-in Kotlin, and sets the minimum SDK constraint to Dart ^3.12.0 / Flutter >=3.44.0.

Flutter 3.50 lowers the pub.dev score of a plugin that still applies the Kotlin Gradle Plugin, even behind an AGP version guard, and that apply fails under AGP 10. The plugin-author guide sets the minimum at Flutter 3.44 / Dart 3.12. That floor is what lets an app build the migrated plugin on AGP 9 with android.builtInKotlin=false. Turning built-in Kotlin on in an example app needs Flutter 3.47, so the examples stay on the off setting.

The thirteen plugins that applied kotlin-android no longer do. When AGP is 9 or newer and built-in Kotlin is on, the plugin sets the JVM target on the extension AGP already registered. Otherwise it waits until Flutter applies org.jetbrains.kotlin.android and sets the target then. plugins.withId is not an apply, so Flutter's detector does not flag it. Cloud Firestore and Firebase Messaging never applied the plugin, so their Gradle files stay as they are.

Apps below Flutter 3.44 keep resolving the current published releases. This follows the same non-breaking treatment as #18634.

Flutter 3.50 stable also refuses the Android toolchain the examples were using. Example apps, the Firestore pipeline example, and tests/android now use the Flutter 3.50 template versions: Gradle 9.5.0, Android Gradle Plugin 9.3.1, and Kotlin Gradle Plugin 2.4.20, with android.builtInKotlin=false and android.newDsl=false. Google Services is 4.5.0, the Crashlytics Gradle plugin is 3.0.8, and the Performance Gradle plugin is 2.0.2. The published plugin constraint stays Flutter 3.44.

Related Issues

Fixes #18956

Fixes the Kotlin Gradle Plugin warning for the migrated plugins once this release is published.

Checklist

Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes ([x]).
This will ensure a smooth and quick review process. Updating the pubspec.yaml and changelogs is not required.

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • My PR includes unit or integration tests for all changed/updated/fixed behaviors (See Contributor Guide).
  • All existing and new tests are passing.
  • I updated/added relevant documentation (doc comments with ///).
  • The analyzer (melos run analyze) does not report any problems on my PR.
  • I read and followed the Flutter Style Guide.
  • I signed the CLA.
  • I am willing to follow-up on review comments in a timely manner.

Breaking Change

Does your PR require plugin users to manually update their apps to accommodate your change?

  • Yes, this is a breaking change.
  • No, this is not a breaking change.

Apps below Flutter 3.44 stay on the current releases. An app that already meets the new floor does not have to change its Gradle files to keep building with built-in Kotlin off.

Test plan

  • Every tracked pubspec is on sdk: ^3.12.0, and every Flutter package pubspec is on flutter: >=3.44.0.
  • No plugin android/build.gradle still contains apply plugin: 'kotlin-android'.
  • dart format reports no further changes at the Dart 3.12 language version.
  • Example and tests/android Gradle configuration succeeds on Flutter 3.50 with Gradle 9.5.0, AGP 9.3.1, and KGP 2.4.20.
  • CI is green.

Melos writes the release notes from the commits. The floor change is feat: update the minimum supported SDK version to Flutter 3.44/Dart 3.12, and the Gradle migration is feat(android): migrate plugins to built-in Kotlin.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the SDK and Flutter constraints across multiple packages, disables the prefer_initializing_formals linter rule, and applies extensive code formatting and style cleanups. The review feedback highlights several violations of the repository's style guide regarding null safety, specifically pointing out the prohibited use of the non-null assertion operator (!) in test files and method channels, and recommends replacing them with proper null checks and flow analysis.

Comment on lines 315 to 319
PersistentCacheIndexManager? indexManager = firestore
.persistentCacheIndexManager();
await indexManager!.enableIndexAutoCreation();
await indexManager.disableIndexAutoCreation();
await indexManager.deleteAllIndexes();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

low

According to the repository style guide (rule 23), the ! operator should not be used. Instead, use flow analysis with a null check to ensure type safety and avoid potential runtime errors.

          PersistentCacheIndexManager? indexManager = firestore
              .persistentCacheIndexManager();
          if (indexManager != null) {
            await indexManager.enableIndexAutoCreation();
            await indexManager.disableIndexAutoCreation();
            await indexManager.deleteAllIndexes();
          }
References
  1. Null Safety: NO ! operator. Use ? and flow analysis (e.g. if (x != null)). (link)

Comment on lines +333 to +338
PersistentCacheIndexManager? indexManager = firestore
.persistentCacheIndexManager();

expect(indexManager, isNull);
} else {
final firestore = FirebaseFirestore.instanceFor(
app: Firebase.app(),
databaseId: 'other-platform-disabled',
);
// macOS, android, iOS have persistence enabled by default so we disable it
firestore.settings = const Settings(persistenceEnabled: false);
PersistentCacheIndexManager? indexManager = firestore
.persistentCacheIndexManager();
expect(indexManager, isNull);
}
},
skip: defaultTargetPlatform == TargetPlatform.windows,
);
await indexManager!.enableIndexAutoCreation();
await indexManager.disableIndexAutoCreation();
await indexManager.deleteAllIndexes();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

low

Avoid using the ! operator on indexManager as per the repository style guide (rule 23). Use flow analysis instead.

Suggested change
PersistentCacheIndexManager? indexManager = firestore
.persistentCacheIndexManager();
expect(indexManager, isNull);
} else {
final firestore = FirebaseFirestore.instanceFor(
app: Firebase.app(),
databaseId: 'other-platform-disabled',
);
// macOS, android, iOS have persistence enabled by default so we disable it
firestore.settings = const Settings(persistenceEnabled: false);
PersistentCacheIndexManager? indexManager = firestore
.persistentCacheIndexManager();
expect(indexManager, isNull);
}
},
skip: defaultTargetPlatform == TargetPlatform.windows,
);
await indexManager!.enableIndexAutoCreation();
await indexManager.disableIndexAutoCreation();
await indexManager.deleteAllIndexes();
PersistentCacheIndexManager? indexManager = firestore
.persistentCacheIndexManager();
if (indexManager != null) {
await indexManager.enableIndexAutoCreation();
await indexManager.disableIndexAutoCreation();
await indexManager.deleteAllIndexes();
}
References
  1. Null Safety: NO ! operator. Use ? and flow analysis (e.g. if (x != null)). (link)

Comment on lines +348 to +353
PersistentCacheIndexManager? indexManager2 = firestore2
.persistentCacheIndexManager();

await indexManager2!.enableIndexAutoCreation();
await indexManager2.disableIndexAutoCreation();
await indexManager2.deleteAllIndexes();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

low

Avoid using the ! operator on indexManager2 as per the repository style guide (rule 23). Use flow analysis instead.

Suggested change
PersistentCacheIndexManager? indexManager2 = firestore2
.persistentCacheIndexManager();
await indexManager2!.enableIndexAutoCreation();
await indexManager2.disableIndexAutoCreation();
await indexManager2.deleteAllIndexes();
PersistentCacheIndexManager? indexManager2 = firestore2
.persistentCacheIndexManager();
if (indexManager2 != null) {
await indexManager2.enableIndexAutoCreation();
await indexManager2.disableIndexAutoCreation();
await indexManager2.deleteAllIndexes();
}
References
  1. Null Safety: NO ! operator. Use ? and flow analysis (e.g. if (x != null)). (link)

Comment on lines +360 to +364
PersistentCacheIndexManager? indexManager = firestore
.persistentCacheIndexManager();
await indexManager!.enableIndexAutoCreation();
await indexManager.disableIndexAutoCreation();
await indexManager.deleteAllIndexes();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

low

Avoid using the ! operator on indexManager as per the repository style guide (rule 23). Use flow analysis instead.

        PersistentCacheIndexManager? indexManager = firestore
            .persistentCacheIndexManager();
        if (indexManager != null) {
          await indexManager.enableIndexAutoCreation();
          await indexManager.disableIndexAutoCreation();
          await indexManager.deleteAllIndexes();
        }
References
  1. Null Safety: NO ! operator. Use ? and flow analysis (e.g. if (x != null)). (link)

Comment on lines +17 to +21
final observerId = await task;

final nativePlatformStream =
MethodChannelFirebaseFirestore.loadBundleChannel(
observerId!,
).receiveBroadcastStream();
MethodChannelFirebaseFirestore.loadBundleChannel(observerId!)
.receiveBroadcastStream();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

low

Avoid using the ! operator on observerId as per the repository style guide (rule 23). Use flow analysis instead.

      final observerId = await task;
      if (observerId == null) {
        throw StateError('Observer ID cannot be null');
      }

      final nativePlatformStream =
          MethodChannelFirebaseStorage.loadBundleChannel(observerId)
              .receiveBroadcastStream();
References
  1. Null Safety: NO ! operator. Use ? and flow analysis (e.g. if (x != null)). (link)

Comment on lines 450 to 455
if (credential is PhoneAuthCredential) {
return auth_interop.PhoneAuthProvider.credential(
credential.verificationId!,
credential.smsCode!,
)
as auth_interop.OAuthCredential;
credential.verificationId!,
credential.smsCode!,
) as auth_interop.OAuthCredential;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

low

Avoid using the ! operator on credential.verificationId and credential.smsCode as per the repository style guide (rule 23). Use flow analysis instead.

  if (credential is PhoneAuthCredential) {
    final verificationId = credential.verificationId;
    final smsCode = credential.smsCode;
    if (verificationId == null || smsCode == null) {
      throw ArgumentError('verificationId and smsCode must not be null');
    }
    return auth_interop.PhoneAuthProvider.credential(
      verificationId,
      smsCode,
    ) as auth_interop.OAuthCredential;
  }
References
  1. Null Safety: NO ! operator. Use ? and flow analysis (e.g. if (x != null)). (link)

@SelaseKay SelaseKay closed this Nov 12, 2026
@SelaseKay
SelaseKay deleted the chore/flutter-3.47-sdk-floor branch November 12, 2026 10:02
@SelaseKay
SelaseKay restored the chore/flutter-3.47-sdk-floor branch November 12, 2026 10:03
@SelaseKay SelaseKay reopened this Nov 12, 2026
@SelaseKay SelaseKay changed the title chore: bump minimum Dart SDK to 3.13.0 and Flutter to 3.47.0 feat(android): migrate plugins to built-in Kotlin on Flutter 3.44 Nov 12, 2026
Flutter 3.44 is the minimum that builds a plugin which no longer applies
the Kotlin Gradle Plugin while android.builtInKotlin is off. Dart 3.12
ships with that release. The Dart 3.13 reformat belonged to the higher floor.
Stop applying the Kotlin Gradle Plugin, including the AGP version guard.
Flutter 3.50 lowers the pub.dev score for that apply line, and AGP 10
rejects it. When built-in Kotlin is on, AGP already provides the kotlin
extension. When it is off, Flutter applies the plugin after this script
and the JVM target is set then.

Updates the minimum supported SDK version to Flutter 3.44/Dart 3.12.
Migrates to built-in Kotlin.
@SelaseKay
SelaseKay force-pushed the chore/flutter-3.47-sdk-floor branch from 319056f to 7189271 Compare November 13, 2026 08:54
Dart 3.12 keeps the public name of a private named parameter, so
this._apiKey is still called as apiKey:. The analyzer flags the old
assignments when infos are fatal.
These two constructors still failed prefer_initializing_formals after
the first pass. The public argument names stay onError and data.
@SelaseKay
SelaseKay merged commit 1abe056 into main Nov 13, 2026
110 checks passed
@SelaseKay
SelaseKay deleted the chore/flutter-3.47-sdk-floor branch November 13, 2026 10:57
erluxman added a commit to erluxman/flutterfire that referenced this pull request Nov 15, 2026
Flutter's KGP check (FlutterPluginUtils.detectApplyingKotlinGradlePlugin)
matches `apply plugin: 'kotlin-android'` in the build script text, so the
AGP 9 guard still gets core, auth, storage, crashlytics, app_check and
cloud_functions named in its "plugins that apply KGP" warning. Flutter
>= 3.44 applies KGP to plugins itself when android.builtInKotlin=false,
so the guard is not needed (upstream firebase#18922, not yet released).

Based on the 2026-10-23 release, BoM 5.1.0 (firebase_core 5.1.0,
firebase_auth 7.0.1, firebase_storage 14.0.1, firebase_crashlytics 6.0.1,
firebase_app_check 0.5.1, cloud_functions 7.0.1).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

Raise the published Flutter floor to 3.44.0

3 participants