For the series “How I did it last time?”, it’s better if this time I write it down to avoid to google it again.
How do I add a custom copyright notice to my android projects?
It is actually relatively simple to do that, you just need to remember which menu and which settings to modify :-).
First of all, you need to decide whether you want to apply your copyright to all your projects in android studio or only to the current opened project.
For all projects, go to: File -> Default Settings.
For the current project only, click the Preference icon showed below.
The rest of the steps are similar for both starting points illustrated above.
Go to Copyright Profiles from Editor -> Copyright.
Click on the “+” icon to create your own Copyright Profile.
Type your Copyright text in next window. Keep in mind that you can use in your text a few variables like:
- $today : for the current date and time;
- $today.year : to access the year information of the current date;
- $username : the currently used username in android studio;
- and others.
Once you finished your text, click on the Validate button to make sure that it complies with the “velocity” template. If it is valid, click on Apply.
At this point go back to the menu item Copyright, where you can now select your newly created copyright from the drop down box. Click again on “Apply/Ok.
Now your copyright is ready to be used. If you create a new file, it will be automatically generated at the top of the file.
In case you want to manually add it to an existing file, then right-click at the top of the file and select “Generate…” as shown below.
A mini-window will open.
Click Copyright and your text will automatically be added at the top of the file!
Obviously you don’t want to repeat this manual update to all your existing files, so I recommend to right-click on any folder of the project as shown in the following picture and to select “Update Copyright…”.
At this point you can choose to add your copyright recursively to the whole project.
It was easy…maybe since I have written it down I will remember how to do it again in future 🙂