The "encoding" of a given source file tells the compiler and the IDE how to interpret the bytes in the file as characters.
The encoding used to compile your project is specified in the build.gradle files. The default, which is used when no specific encoding is specified, is UTF-8. We strongly recommend you use UTF-8 encoding whenever possible. The Android development tools create UTF-8 encoded projects by default, the Android Gradle plugin uses UTF-8 by default, and Android Lint will warn whenever it encounters XML files that are not using UTF-8, for example.
However, it is possible to change the encoding used by the IDE, both at the IDE level (which becomes the default for all loaded projects), on a per project level, and even on a per file level. This is specified in the Settings dialog under Editor > File Encodings.
However, this does not affect how the build system (Gradle) treats these files. This means that you can view and edit your files in the IDE using one encoding, and then having them translated by the build system using a different encoding. This can lead to really surprising and serious bugs (such as issue 163078).
If you do change the encoding in the IDE, make sure you also update the Gradle files to reflect these encodings:
As of Android Studio 1.2, we detect a mismatch between the encoding specified in Gradle and the encoding used by the IDE:
When you encounter the above problem (which points to the this page), either change your IDE settings or build.gradle to UTF-8 such that the two matches, or (if necessary) change your encoding to whatever custom encoding you have specified such that the two are in agreement.
(Note: If your source files contain more than plain ASCII characters, you can't "just" change the encoding to UTF-8. If your source files were written with a custom encoding, you'll need to convert them such that the actual characters are read in with the previous encoding and written out with the new encoding.)
In a future version of the IDE, we plan to force the encoding specified in the build.gradle files to be pushed into the IDE, in the same way that the Java language setting already is.
Known Issues >