1.3 KiB
Setting up Kotlin formatting in Android Studio
Kotlin code in this repository is formatted and linted with ktlint.
If you
- have submitted Kotlin code only to learn this when the analyzer check fails
- use Android Studio
then there is good news! Android Studio can be configured to use ktlint to automatically apply formatting and highlight issues. To do this:
-
Install the
ktlintextension for Android Studioa. On Mac, this is
Android Studio > Settings > Plugins >Search forktlint. -
Set the ruleset to be the same as the version used in
.ci.yaml(as of writing this is 1.5), and the baseline to bedev/bots/test/analyze-test-input/ktlint-baseline.xml.a. Both of these options should be available under
Android Studio > Settings > Tools > ktlint. -
Additionally, Kotlin code in the Flutter repository currently uses some additional rules for compatibility with older versions of Kotlin. These rules can only be configured by an
.editorconfigfile in the directory from which Android Studio was opened. To configure these rules, create a copy of the.editorconfigthat is used by tests in the root directory you intend to open with Android Studio.