在 Android Studio 3 中将 androidManifest.xml 的编码更改为 UTF-8 [英] Change encoding of androidManifest.xml to UTF-8 in Android Studio 3

查看:27
本文介绍了在 Android Studio 3 中将 androidManifest.xml 的编码更改为 UTF-8的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 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(gradle 版本 2.3.x)和 Adnroid Studio 3 Beta 和 RC-1(gradle 版本 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://developer.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):

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

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.

这篇关于在 Android Studio 3 中将 androidManifest.xml 的编码更改为 UTF-8的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆