Android Studio 1.2 - Project encoding mismatches by default
I am or was having the same problem. So I changed it so that the IDE and project encodings and the default encoding for properties files were all UTF-8. But I kept seeing the same warning in the gradle sync tab of the messages. Then eventually I simply closed that tab, and have not seen the warning message since. Presumably the IDE would reraise that tab if the warning condition again applied. Now when I make the project, neither the gradle sync tab nor the warning message appear. So maybe the warning was written appropriately during one make, but should have been cleared or somehow removed at the start of a new make, but wasn't, meaning that it is a bug in the IDE.
But every time I create a new project, the problem comes up again. There ought to be a setting to cause all the encodings to match every time a new project is created.
You can change the default encoding settings for new projects by clicking on File -> Other Settings -> Default Settings.
Under "Editor" and "File Encodings" you can set IDE Encoding and Project Encoding to the same value to avoid getting the error message with future projects.
Setting it under File -> Settings will change it just for the currently open project.
Instead of changing UTF-8 to match system default, I would recommend to set your Project Encoding to UTF-8 (File -> Settings -> Editor -> File Encodings). UTF-8 is one of the most common file encodings, and it uses space efficiently by encoding characters from using 1 to 4 bytes as needed.
Google recommends using UTF-8, and both Gradle and Android Lint use UTF -8: File Encoding for Android Studio
I had the exact same issue after upgrading to Android Studio 1.2.
Click File -> Settings (or click Ctrl + Alt + S) and find File Encodings in your Android Studio. See the image below as a reference.
Now you have three options
- Change project encoding to match UTF-8 since both Gradle and Android Lint use this (recommended),
- or change IDE encoding to match other encoding,
- or just simply ignore the warning. If it worked out for you so far, it will continue to work anyway
(source: shrani.si)
Once you see the warning, you can directly click on "Open File Encoding Settings" as shown in the image below. This will take you to the same place as described above.
You can also see the current encoding of your file at the bottom right corner of Android studio. You can also change it there. See the image below.
Also you can specify charset in your build.gradle script like this
android {
...
compileOptions {
encoding "UTF-8"
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
}
According to Ashl7's comment, you need to do a gradle sync for this to work