Change encoding of androidManifest.xml to UTF-8 in Android Studio 3

只愿长相守 提交于 2019-12-03 22:29:02

问题


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?


回答1:


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

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.

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

More info: https://developer.android.com/studio/build/gradle-plugin-3-0-0.html

UPDATE:

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

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.



来源:https://stackoverflow.com/questions/46789253/change-encoding-of-androidmanifest-xml-to-utf-8-in-android-studio-3

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!