Skip to main content

Developer setup

Android Studio

Use Android Studio 4.2+.

Kotlin style

If you would like Android Studio to help format your code, follow these steps to set up your Android Studio:

  1. Install and configure the ktfmt plugin in Android Studio by following these steps:
    1. Go to Android Studio's Settings (or Preferences), select the Plugins category, click the Marketplace tab, search for the ktfmt plugin, and click the Install button
    2. In Android Studio's Settings (or Preferences), go to Editorktfmt Settings, tick Enable ktfmt, change the Code style to Google (Internal), and click OK
  2. Indent 2 spaces. In Android Studio's Settings (or Preferences), go to EditorCode StyleKotlinTabs and Indents, set Tab size, Indent and Continuation indent to 2, and click OK.
  3. Use single name import sorted lexicographically. In Android Studio's Settings (or Preferences), go to EditorCode StyleKotlinImports, in Top-level Symbols and Java statics and Enum Members sections select Use single name import option, remove all the rules in Packages to Use Imports with '*' and Import Layout sections and click OK.

Now you can go to CodeReformat code, or press Ctrl+Alt+L (⌘+⌥+L for Mac) to automatically format code in Android Studio.

Note that you don't have to do any of these. You could rely on spotless to format any code you want to push. For details see below.