Android Studio “This file is indented with tabs instead of 4 spaces”

独自空忆成欢 提交于 2019-11-28 07:13:05
Suragch

The JetBrains IntelliJ IDEA Blog states:

If you’ve already tried the latest IntellIJ IDEA 14 EAP build, you might’ve noticed that the Code Style settings offers a new option: Detect and use existing file indents for editing (enabled by default.)

This new option lets IntelliJ IDEA detect certain Code Style settings (such as Use Tab character and Indent size) in the currently edited file on the fly. It means that even if a file has a code style different from your current settings, they will still be preserved.

So now you don’t need to worry about losing the formatting in files that are specific to certain files in your project that differ from the others.

You can see that option checked in the following image:

The project you imported from Eclipse used tabs rather than spaces for indenting. Android Studio allows you to keep this code style. However, if you don't want the reminders, you can do one of the following things:

Fixes

Any of the following will work:

  • Uncheck the Detect and use existing file indents for editing setting.

  • Change your default indenting for Java (not just on the general Code Style page). Go to File > Settings > Editor > Code Style > Java. On the Tabs and Indents tab click "Use tab character".

  • Convert Tabs to Spaces. Just click "Indent with 4 spaces" whenever the warning comes up. Or go to Edit > Convert Indents > To Spaces.

See also:

Not sure about prior versions, but using Android Studio 2.2.3, Build #AI-145.3537739, built on December 2 2016, you have an option from Settings > Editor > Code Style that allows you not to show the notifications.

Uncheck it, and they'll disappear!

Show notifications about detected indents

Turn on "Use tab character" (File -> Settings -> Editor -> Code Style -> JAVA).

If Not working do this also, Turn on "show whitespaces" (Editor -> General -> Appearance).

If you are using IntelliJ ultimate, you have the option "Show notifications about detected indents". Uncheck this.

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