简体   繁体   中英

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. I'm getting below error message while trying to load these files.

file was loaded in wrong encoding UTF-8

package directive does not match file location.

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.

相同 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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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