简体   繁体   English

以错误编码 UTF-8 加载的文件,在 windows-1252 android studio 中重新加载

[英]File loaded in wrong encoding UTF-8 , Reload in windows- 1252 android studio

I'm working on project having multiple Git branches.After switching to different branch, few java & Kotlin source files are fine and few are showing encoded source files, even when I build and run project it work fine.我正在研究具有多个 Git 分支的项目。切换到不同的分支后,很少有 java 和 Kotlin 源文件可以正常工作,即使我构建的源文件也可以正常运行,并且项目也可以正常运行。 I'm getting below error message while trying to load these files.我在尝试加载这些文件时收到以下错误消息。

file was loaded in wrong encoding UTF-8文件以错误的编码加载 UTF-8

package directive does not match file location. package 指令与文件位置不匹配。

and sometimes it also gets stuck.有时它也会卡住。 It was working fine with other branches.它与其他分支机构一起工作得很好。

I tried few hacks like, clean/rebuild / delete build folder, etc but still of no use.我尝试了一些技巧,例如清理/重建/删除构建文件夹等,但仍然没有用。

I'm unable to see my java, Kotlin & xml code but when I open these files in notepad it work fine.我看不到我的 java、Kotlin 和 xml 代码,但是当我在记事本中打开这些文件时,它工作正常。

相同 1

设置

视图1

so what I did was I added the below piece of code in my Gradle file compile options , cleaned the project, and invalidate and restarted android studio.所以我所做的是我在我的 Gradle 文件编译选项中添加了以下代码,清理了项目,并使 android 工作室无效并重新启动。

compileOptions {
    
    compileOptions.encoding = 'windows-1251' //'UTF-8'
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM