Nathan Blair
Nathan Blair

Reputation: 963

Android Studio Resetting Changes to Default Code Style

I'm here today because I'm having an issue with Android Studio. I don't know if it existed on previous versions (I don't remember this being an issue, so I doubt it was a problem on a previous version), but currently I am using the Android Studio V2.1 Stable release.

My issue is that if I launch Android Studio (I happen to be on Windows, 64-bit Android Studio) and at the Start Screen/Page, I click Configure>Settings>Editor>Code Styles, and change the default parameters on any of the languages (XML, Java, HTML, etc.), the Default profile is copied to a new profile (Default(1)) and the new settings get applied to each profile.

If I Apply these changes and exit Android Studio, and launch back up and follow the same method...the settings have completely gone back to what they were before I changed them, with the exception of the Default(1) copy profile. But from my experience, Android Studio doesn't build new projects based on this Default(1) copy profile, it builds them on the Default profile. Which means all of my adjustments to using indents and not spaces, keeping indents on empty lines, etc. all do not get carried through to the actual project files, leaving me to have to go back into the settings with the project loaded up and change all of these parameters again. That's just asinine. Please tell me I'm missing something here and that there's a simpler way of achieving the ability to keep a code style template that I can use on all of my projects!

Perhaps it would be better to report or consult on this using the Android Studio feedback site. If that's the better option, I'm willing to do that too.

Thanks everyone!

Upvotes: 31

Views: 6698

Answers (5)

Georgiy Chebotarev
Georgiy Chebotarev

Reputation: 3190

For me nothing from these didn't help. So, I cleared project and closed it. Then I removed build and .edia folders from project folder and opened project again. After rebuilding it keept an official code style -> problem was resolved.

Upvotes: 0

Pierre Vieira
Pierre Vieira

Reputation: 3300

  1. Go to Preferences
  2. Code Style
  3. Set Scheme to Default [IDE]
  4. Click restore defaults

Restore defaults

Upvotes: 3

George
George

Reputation: 2997

The simplest way I found to reset the default settings is as follows:

  1. In Android Studio, click on File.
  2. Settings (Ctrl + Alt + S)
  3. Under Editor in settings
  4. Select Code Style
  5. Next to Scheme: select the three dots to access the scheme options ()
  6. Select Restore Defaults
  7. A Confirmation Dialog Box will be displayed to confirm if you want to revert back to the default settings.

Settings Screen

Upvotes: 1

ked
ked

Reputation: 2456

After selecting the code style that i want, opened the gradle.properties file in root folder of the project and deleted the following line

kotlin.code.style=official

deleting the above line, prevents the code style resetting to default.

Upvotes: 16

svkaka
svkaka

Reputation: 4022

What I do in that case is

  1. Go to Preferences
  2. Code Style
  3. Select scheme you want
  4. Click Settings cog
  5. Click copy to project

Some OKs and then it works. enter image description here

Upvotes: 20

Related Questions