IntelliJ/Android Studio 中一个文件的错误文件关联

我不小心创建了一个没有。Xml 扩展名。在将该文件关联为其他类型之后,我立即单击了另一个对话框... ?在将文件重命名为包含。Xml 文件仍然没有语法突显。我试过关闭 Android Studio,删除文件,重新创建等等。它仍然以普通文件的形式出现。如果我创建一个具有不同的。Xml 文件,它与。

有什么想法吗?

24273 次浏览

Look in the Preferences > Editor > File Types under Text files, the name of your file is probably there, remove it.

Preferences > Editor > File Types


If you cannot find it there, the next option is to search IntelliJ's caches for the name of the file, e.g., find . -name "*.xml" | xargs grep "Whoopsies". IntelliJ has to be remembering that value somehow...


The cache locations depends on your operating system and IntelliJ version (source).

Windows

Windows Vista, 7, 8:

\Users\[USER ACCOUNT NAME]\.[PRODUCT][VERSION]

Windows XP:

[SYSTEM DRIVE]\Documents and Settings\[USER ACCOUNT NAME]\.[PRODUCT][VERSION]

*nix

~/.[PRODUCT][VERSION]

Mac OS X

Configuration:

~/Library/Preferences/[PRODUCT][VERSION]

Caches:

~/Library/Caches/[PRODUCT][VERSION]

Plugins:

~/Library/Application Support/[PRODUCT][VERSION]

Logs:

~/Library/Logs/[PRODUCT][VERSION]

I got the same sort of problem. I found my file in the following File Type:

enter image description here

What seemingly worked for me on macOS Mojave 10.14.1 is removing ~/Library/Preferences/AndroidStudio3.2, but this will reset every setting to the default.

I found it under the 'Auto-detect file type by content' file: Preferences/Editor/FileTypes

I had the same issue where I accidentally had a file be auto-detected as text in IntelliJ Idea.

Unfortunately whenever I would go to the File Types dialog like other answers suggest I could never find it there.

So I went to my IntelliJ configuration folder (see here for where to find it) which for me was in ~/AppData/Roaming/JetBrains/IntelliJIdea2021.1/options and found the fileTypes.xml file.

In there I found the line which contained the association for my specific filename and deleted it and saved the file.

Then I closed IntelliJ and reopened it and it worked.

just try to add a file into text file types, apply, after remove it and apply one more time. helped for me

For what it's worth I myself found myself a victim of this one. Searched in vain to find any trace of this in cache files.

Managed to fix it by going back to Preferences/Editor/File Types then (because it was a kotlin type) typing the filename, in full, into the section File name patterns for Kotlin. Selecting reassign when a dialog pops up finally fixed this one - for me at least