在Android Studio 3中将androidManifest.xml的编码更改为UTF-8

问题描述:

在Beta版本的Android Studio 3中,即使标头中声明了UTF-16,似乎androidManifest文件也被强制编码为UTF-8. 这是一个错误还是现在还有另一种方法可以将清单的编码改回UTF-8?

In the beta version of Android Studio 3 it seems that the androidManifest file is encoded forcefully into UTF-8 even if UTF-16 is stated in the header. Is this a bug or is there another way now to change the encoding of the manifest back to UTF-8?

在Android Studio 3(测试版和RC-1)中使用gradle构建应用的过程正在使用aapt2.

The app build process using gradle in Android Studio 3 (beta and RC-1) is using aapt2.

我比较了由Android Studio 2.x(版本2.3.x)和Adnroid Studio 3 Beta和RC-1(版本4.1)生成的AndroidManifest.xml.比较的结果是,对于Android Studio 2.x,清单编码为UTF-16LE,对于Android Studio 3和新工具,清单编码为UTF-8 ...,这恰好与您在本文档中提到的相反上面的问题.

I compared the AndroidManifest.xml generated by the Android Studio 2.x (gradle version 2.3.x) and Adnroid Studio 3 Beta and RC-1 (gradle version 4.1). The result of the comparison is that with Android Studio 2.x the manifest encoding is UTF-16LE and with Android Studio 3 and the new tools, it is UTF-8... which happens to be the opposite of what you mentioned in the question above.

gradle.properties文件中使用android.enableAapt2=false,会导致使用旧aapt的构建系统.

Using android.enableAapt2=false in the gradle.properties file, results in the build system using the old aapt.

更多信息: https://开发人员. android.com/studio/build/gradle-plugin-3-0-0.html

更新:

昨天(10月23日)有这条推文( https://twitter.com/the_very/状态/922564040961826816 ):

There is this tweet from yesterday (Oct 23rd) (https://twitter.com/the_very/status/922564040961826816):

gradle.properties中添加systemProp.file.encoding=UTF-8以修复本地版本和服务器版本中的所有编码问题

add systemProp.file.encoding=UTF-8 to gradle.properties to fix all encoding problems in both local and server builds

它确实对我有用.希望对您有帮助.

It does work for me. I hope it helps you too.