Android Studio 1.2 - default design encoding mismatch

I'm a little new to Android, and I just upgraded to Android Studio 1.2. When I create a new project (API 16: Android 4.1 (Jelly Bean)), I immediately get the following warning:

Warning. The encoding of the project (windows-1252) does not match the encoding specified in the Gradle assembly files (UTF-8). This can lead to serious errors. | More info ...
Open File Encoding Settings

This is without me, making any changes or writing any code. I read additional information about tools.android.com ( http://tools.android.com/knownissues/encoding ), but it is incredibly vague and suggests knowing what is happening (this is where "More Information ..." takes you) . Since I upgraded to Android Studio 1.2, the design and text tabs in my XML files do not even sync; the Design tab cannot be edited, while a text file of XML files can be. I assume there is a problem with this.

Why does this not match this default encoding, what can I do with it and what should I use as the default encoding?

Thank!

+43
android intellij-idea android-studio encoding
May 03 '15 at 10:01
source share
4 answers

Click File → Preferences (or press Ctrl + Alt + S ) and find File Encodings in your Android studio. See the image below for help.

You now have three options.

  • Change the project encoding according to UTF-8, since Gradle and Android Lint use this (recommended),
  • or change the IDE encoding to match a different encoding,
  • or just ignore the warning. If this still works, it will continue to work anyway.

http://shrani.si/f/3V/p7/5xt1uxV/encoding.png

As soon as you see a warning, you can immediately click "Open file encoding settings", as shown in the figure below. This will lead you to the same place as described above.

enter image description here

You can also see the current encoding of your file in the lower right corner of Android Studio. You can also change it there. See image below.

IDE Encoding

You can also 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 comment , you need to do Gradle sync for this to work

+79
May 03 '15 at 10:05
source share

Instead of changing UTF-8 to meet the system standard, I would recommend setting the project encoding to UTF-8 (File → Settings → Editor → File encodings). UTF-8 is one of the most common file encodings, and it efficiently uses space by encoding characters 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 same problem after upgrading to Android Studio 1.2.

Screen capture of Android Studio settings window

+15
May 12 '15 at 18:26
source share

I or have the same problem. So I changed it so that the IDE and project encodings and the default encoding for the property files were UTF-8. But I continued to see the same warning on the gradle message synchronization tab. Then I just closed this tab and did not see a warning message. The IDE will presumably repeat this tab if the warning condition is reapplied. Now when I do the project, neither the gradle sync tab nor the warning message appear. Therefore, perhaps the warning was properly written during one make, but it should be cleared or somehow removed at the beginning of the new make, but it did not, which means that this is an error in the IDE.

But every time I create a new project, a problem arises again. There should be a setting in which all encodings will match every time a new project is created.

+5
May 13 '15 at 2:59
source share

You can change the default encoding settings for new projects by clicking File → Other Settings → Default Settings.

In the "Editor" and "File Encodings" sections, you can set the IDE encoding and the project encoding to the same value in order to avoid receiving an error message with future projects.

The setting in the "File → Settings" section will change it only for the current open project.

+2
Jun 03 '15 at 18:33
source share



All Articles