| type | rfc | ||
|---|---|---|---|
| rfc | 720.0001 | ||
| title | Kotlin in First-Party Android Plugins | ||
| description | Adopts Kotlin as the preferred language for first-party Android plugins. | ||
| status | stable | ||
| created | 2026-09-15 00:00:00 UTC | ||
| updated | 2026-09-15 23:34:59 UTC | ||
| tags |
|
||
| authors |
This document proposes updating
the official 1P plugin language policy
to make Kotlin the preferred language for the implementation of plugins in the
flutter/packages repository. This is a follow-up to
the 2021 design document
which was never adopted, incorporating developments since that proposal.
A number of significant changes have taken place since the 2021 proposal (see also issue 188630 for more discussion):
- Pigeon is used for all plugins, and its new development focuses on Kotlin,
not Java, due to the cost of developing features multiple times and the
use of Kotlin as the default for new plugins in
flutter create.- We are strongly considering dropping the Java generator entirely, and have migrated to the Kotlin generator in all plugins, making the current plugins a Java/Kotlin hybrid (although with almost all Kotlin code being generated rather than human-maintained).
- Several of our plugins have migrated to Kotlin in order to better dogfood Pigeon features. This means that adopting Kotlin no longer increases the total number of languages in the repository.
- Gradle files have all been migrated from Groovy to Kotlin, which also
increases the general use of Kotlin (although
.ktsfiles are in many ways not typical of plugin-style Kotlin code). - AI is now a core part of most development workflows, which has several
impacts:
- The volume of code to be reviewed is increasing, which makes the
compile-time safety of Kotlin more valuable. For example, reviewers don't
have to do complex reasoning about whether code could cause NPEs at runtime.
Similarly, using Pigeon's new Kotlin
suspendsupport instead of callback-based APIs ensures that exactly one reply is sent for each message.- Agents that iterate on changes until all tests pass can also more reliably find their own errors before human review, since they will receive compile-time errors for more bugs than they would in Java.
- With Kotlin as the default language for Android development in general, AI
tooling is likely to have better training data for Kotlin-based plugins, and
thus produce better code.
- Similarly, our own code will be more useful to the community as a source of training data or reference context for AI agents asked to implement functionality in third-party plugins.
- Agent reviews mitigate the lack of Kotlin expertise on the team, since agentic reviews can help fill the role of language-expert reviewers by providing guidance on idiomatic patterns based on large amounts of training data.
- The volume of code to be reviewed is increasing, which makes the
compile-time safety of Kotlin more valuable. For example, reviewers don't
have to do complex reasoning about whether code could cause NPEs at runtime.
Similarly, using Pigeon's new Kotlin
This document proposes replacing the current policy with the following:
Android: Depends on the plugin. For non-migration PRs use:
- Kotlin if the plugin is already in Kotlin, or for new plugins.
- Kotlin when adding a new file to a Java or mixed-language plugin, unless there are interop issues with existing Java code that make doing so difficult.
- Kotlin when adding new tests (when feasible).
- Java when modifying existing Java code.
- Note: Only Flutter team members may migrate an existing plugin's Java code to Kotlin, due to the potential difficulty of reviewing such PRs; migration PRs from non-team members will be rejected.
This proposal does not assume the migration of existing Java-based plugins from Java to Kotlin; instead, it is based on the premise that incremental adoption of Kotlin is a net gain even when it results in mixed-language plugins.
However, given that a number of the benefits above apply to ongoing maintenance of existing code as well, team members should consider the potential value of incremental migrations. Migration can also serve as a way for team members to increase their own familiarity with Kotlin. This issue comment lays out a recommended migration strategy that minimizes the risk of regressions during migration, as well as the review cost, by relying primarily on a deterministic migrator.