Android Studio: how to remove/update the "Created by" comment added to all new classes?

Android StudioIntellij Idea

Android Studio Problem Overview


By default Android Studio automatically adds a header comment to all new classes, e.g.

/**
 * Created by Dan on 11/20/13.
 */

Where is the setting to customize or remove it?

Android Studio Solutions


Solution 1 - Android Studio

From the menu bar:

  • on Mac OS choose Android Studio -> Preferences
  • on Windows and Linux choose File -> Settings

Then look for Editor -> File and Code Templates in the left hand pane.

You have two ways you can change this...

  1. Select the Includes tab and edit the Created by... text directly.

enter image description here

  1. Select the Templates tab and edit the #parse("File Header.java") line for any template that you desire.

templates tab edit

Personally I followed option 1) and made the default header comment a TODO, e.g.

/**
 * TODO: Add a class header comment!
 */

These instructions are based on Android Studio v0.3.7. and also tested on v1.2.1.1

Solution 2 - Android Studio

You can overwrite the ${USER} variable in the template file with the #set( $VARIABLE = "value") function.

On windows: Press Ctrl+Alt+S and go to Settings -> File and Code Templates -> Includes -> File Header

On Mac: Android Studio -> Preferences -> Editor -> 
File and Code Templates -> Includes -> File Header

prepend the #set() function call, for example:

#set( $USER = "YourName" )
/**
* Created by ${USER} on ${DATE}.
*/

Solution 3 - Android Studio

As well as Dan's answer (which is the much more rigorous way), you can also click into the header, and option-enter (on Mac), and you can choose to edit the default file template. Alternatively, click the little lightbulb to get here as well

enter image description here

Solution 4 - Android Studio

Change Android Studio File Header Template

Step 1: First hover over the File Header and get the yellow lightbulb and the menu out of it by clicking on it as shown in the following screenshot:

yellow lightbulb menu > Edit template

Step 2: Then click on the Edit template menu item and get the following pop-up window:

Edit File Template pop-up window

Note: In its Description area there are many other available Template variables, you can use them too.

Step 3: In the editor area add your name as shown in the following screenshot and click "OK" button and the current file and the future new class file headers will be generated accordingly.

Updated header template configuration

Hope this answer will be helpful to somebody else out there! :-) Cheers! (This works on Android Studio 2.2 (September, 2015) version.)

Solution 5 - Android Studio

Accepted answer had instructions for Android Studio v0.3. so I decide to add instructions for Android Studio 3.0.1

  • Go to Android Studio Preferences-> CopyRight->CopyRightProfiles and click on [+] to add a new profile or edit existing profile.

enter image description here

  • Create or update copyright template, a sample template can be copied from below:

> Creator: Hitesh Sahu on $today > Last modified: $file.lastModified > Copyright: All rights reserved Ⓒ $today.year http://hiteshsahu.com >
> Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. > You may obtain a copy of the License at > http://www.apache.org/licenses/LICENSE-2.0 > Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" > BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or > implied. See the License for the specific language governing > permissions and limitations under the License.

enter image description here

  • Now select that newly created copyright as your default copyright profile

enter image description here

  • Lastly update copyright of entire project like below

    enter image description here

Solution 6 - Android Studio

  1. Press ctrl+shift+A
  2. Type : File and Code Templates.
  3. Look for File Header under Includes
  4. You can type something like below

enter image description here

Solution 7 - Android Studio

In case you want to remove all comments which have already been created. Hit Ctrl + Shift + R to open the Replace in path dialog. Check the Regex option and replace

/\*\*\n \* Created by .*\n \*/

with nothing.


The regex was originally posted by nerdinand as comment to the following answer. Although I asked him, he didn't create an answer for several months. That is why I did now, so people can find this more easily.

Solution 8 - Android Studio

You can just disable the warning as well. For me the default template was ok but seeing yellow highlighted class javadoc was annoying me. So to disable it go to Settings -> Editor -> Inspections -> General -> Uncheck "Default File Template Usage".

You can also do it accross all projects. Just change the Project profile to Default in the same Inspections tab.

Solution 9 - Android Studio

> Settings->Editor->Copyright->Copyright Profiles

is another place (apart from "Settings->Editor->File and Code Templates") where similar template could be defined and also triggered whenever file is created.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionDan JView Question on Stackoverflow
Solution 1 - Android StudioDan JView Answer on Stackoverflow
Solution 2 - Android StudioCüneytView Answer on Stackoverflow
Solution 3 - Android StudioJeeterView Answer on Stackoverflow
Solution 4 - Android StudioRandika VishmanView Answer on Stackoverflow
Solution 5 - Android StudioHitesh SahuView Answer on Stackoverflow
Solution 6 - Android StudioBalwinder SInghView Answer on Stackoverflow
Solution 7 - Android StudioWilli MentzelView Answer on Stackoverflow
Solution 8 - Android StudioVito ValovView Answer on Stackoverflow
Solution 9 - Android StudioshtolikView Answer on Stackoverflow