机器人工作室1.2 - 项目编码不匹配默认机器人、不匹配、工作室、项目

2023-09-13 00:37:48 作者:哥、一表人渣

我有点一个Android新秀,我刚刚升级到Android 1.2工作室。当我提出一个新的项目(API 16:Android的4.1(果冻豆)),我立即得到以下警告:

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

警告:该项目编码(窗口1252)不匹配   在摇篮指定的编码生成文件(UTF-8)。这可能导致   严重的错误。 更多   信息... 打开文件编码   设置

Warning:The project encoding (windows-1252) does not match the encoding specified in the Gradle build files (UTF-8). This can lead to serious bugs. More Info...Open File Encoding Settings

这是我没有作出任何更改或任何书面的任何code。我读了关于tools.android.com的详细信息(http://tools.android.com/knownissues/encoding)但令人难以置信的是模糊的,并假设知识是怎么回事(这就是更多信息...需要你)。自从我更新到Android 1.2工作室,设计和文字标签在我的XML-文件甚至不会同步起来;设计选项卡无法进行编辑,而XML的文件,文本文件可我认为这是一个相关的问题

This is without me having made any changes or written any code whatsoever. I read up on more info on tools.android.com (http://tools.android.com/knownissues/encoding) but it is incredibly vague and assumes knowledge on what's going on (this is where "More info..." takes you). Since I updated to Android Studio 1.2, the design and text tabs in my XML-files won't even sync up; the design tab cannot be edited while the textfile of XML-files can be. I assume that's a related issue.

为什么它不匹配这个编码在默认情况下,我能做些什么,并为缺省编码,我应该怎么用?

Why does it mismatch this encoding by default, what can I do about it and what should I use as default encoding?

感谢您!

推荐答案

点击文件 - >设置(或单击控制 + 替代 + 取值),并找到你的Andr​​oid Studio的文件编码。见下面的图片作为参考。

Click File -> Settings (or click Ctrl + Alt + S) and find File Encodings in your Android Studio. See the image below as a reference.

现在,你有三种选择

更改项目的编码,以匹配UTF-8,因为这两个摇篮和 Android的皮棉使用这个(推荐), 或更改IDE编码,以配合其他编码, 或只是简单地忽略警告。如果它的工作适合你,到目前为止,它仍然继续工作 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

在您看到这些警告,可以直接点击打开文件编码设置,如下图所示的图片。这将带您到同一个地方,如上所述。

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.

您还可以看到你的文件的当前编码在Android的工作室的右下角。你也可以有改变。见下图。

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.

你也可以在这样的build.gradle脚本指定字符集

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
    }
}