Adding this plugin provides real-time feedback against a given CheckStyle profile by way of an inspection. to add, grab the Checkstyle-idea plugin, install and restart Studio.
Open Preferences..
in Android Studio and navigate to Other Settings
. Add the checkstyle by pressing the plus button:
and grabbing the checkstyle.xml
file found in the cloned repo:
Give a description click next and then finish:
Make sure to check the new style to actually apply it in Android Studio. Last thing I do (but is an optional) is to check the Treat Checkstyle errors as warnings
.
To make the formatting quick and easy, you'll most likely want to change the code style set in Android studio. Open Preferences..
in Android Studio if it isn't open already and select Editor -> Code Style
at the top under Scheme
click the manage button:
Chose either project (to change the project style only) default, or make a new on. Click import and add the checkstyle.xml
file:
Ensure that the style you imported the checkstyle to is selected in the dropdown menu now and click apply. Now when you are in a java file, all you have to do is press [command][option][l]
(on Mac) and the file indentions and other formatting mistakes.