How to add copyright to Android-Studio?
Asked Answered
S

8

54

The title says everything. If I want to add copyright comment in code files in Android Studio? I, of course, find the Copyright settings in Preference/Copyright, but I can't make it work... copyrights just don't appear when I create a new Java file.
Is it a bug of Android Studio or did I miss something ?

Setscrew answered 27/6, 2013 at 14:4 Comment(0)
G
54

On the file you want to insert the copyright notice you have to press Alt+Insert for Windows and GNU/Linux or Command+N for Mac and select the copyright to be inserted.

http://www.jetbrains.com/idea/webhelp/generating-and-updating-copyright-notice.html

Gibeonite answered 12/10, 2013 at 19:17 Comment(0)
D
38

File > Settings > Editor > Copyright > Copyright Profiles > + add -> profile name

Sample Copyright Template Text

/**
 * Created by $username on $today
 * Copyright (c) $today.year . All rights reserved.
 * Last modified $file.lastModified
 */

If you need any extra variables, please visit source Copyright Profiles

Danseuse answered 10/2, 2018 at 8:20 Comment(4)
Is there any command to get the file's actual created date instead of $today?Puffball
@Puffball please follow this variables only available jetbrains.com/help/idea/copyright-profiles.htmlDanseuse
For new versions, Go to Android Studio> PreferencesGarneau
marked the answerCallis
S
29

You need to first create a copyright profile (Settings | Copyright | Copyright profiles), then go to Settings | Copyright and change the default copyright.

Spiegeleisen answered 27/6, 2013 at 16:30 Comment(1)
Can I share my copyright between projects? Every time I create a new project, i have to add a new copyright profile to the new project which is annoying.Impair
G
17

Go to Settings> Copyright> Copyright Profiles. Create one copyright profile. Then go to Settings | Copyright and change the default copyright to the one which you created and Apply>Ok.

And from the top menu Click Code -> click Update copy right and select the files you want to apply.

Gamache answered 17/3, 2017 at 18:50 Comment(2)
Couldn't figure out why my changes weren't showing up. Thanks.Dimetric
Yes, thanks for explaining how to update default after adding the Copyright Profile.Hustings
E
10

After you have configured the copyright settings and copyright profiles (Settings > Editor > Copyright) for your project, you can:

  • (Windows) Use Alt + Insert in an opened file to present the option for adding/updating the copyright
  • (Mac) Use Command + N in an opened file to present the option for adding/updating the copyright
  • Right click a directory or file in Android Studio's project view, and select "Update Copyright..."
Ezarra answered 1/1, 2016 at 19:49 Comment(0)
L
2

You can find file header in Preference menu.

Android Studio - Preference - File and Code Templates

Select includes Tab. You can edit file header.

Leahy answered 2/1, 2014 at 2:34 Comment(0)
E
2

Go to Preferences | Search " Copyright " -> Add New Copyright Profile -> then select default copyright for project.

    Created by YourName on $today
    [email protected]
    Last modified $file.lastModified
    Copyright (c) $today.year.  
    All rights reserved.
Estren answered 10/6, 2021 at 13:50 Comment(0)
C
2

1 - To add or update copyright in android studio, go to Settings > Copyright > Copyright Profile (or Preferences > Editor > copyright in Mac).

2 - Create your copyright profile, add your message and apply the changes.

3 - Now again go to copyright, add the profile you created as the default copyright and apply the changes.

4 - Not go to Code option at the top menu and click on update copyright, select the scope(a file, or a module, or whole project as per requirement).

5 - In case you are updating the copyright again, it is possible that the update copyright option might now be activated, try restarting the studio or invalidating cache and restart. The option should be clickable.

Cretin answered 26/6, 2021 at 12:58 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.