How to Change Author Template in Android Studio: Replace Automatic Employee Number with Your Name
When working on Android projects, Android Studio automatically generates header comments for new files (e.g., Java/Kotlin classes, activities, fragments). These headers often include an @author tag, which by default uses the system username. In many corporate environments, this username might be an employee ID (e.g., emp12345) instead of a human-readable name (e.g., John Doe). This can lead to confusion in collaborative projects, where clear authorship is essential for code reviews, debugging, and documentation.
In this blog, we’ll walk through two methods to customize the author template in Android Studio:
Directly editing the file header template to replace the employee number with your name.
Overriding the USER variable in Android Studio settings to globally set your name for all templates.
By the end, you’ll ensure every new file you create in Android Studio displays your name as the author, making your contributions clear and professional.
Understanding the Author Template in Android Studio#
Android Studio uses file templates to generate boilerplate code for new files. These templates include variables (e.g., ${USER}, ${DATE}, ${TIME}) that the IDE replaces with dynamic values when a file is created. The @author tag in headers typically uses the ${USER} variable, which defaults to your system’s username. If your system username is an employee ID (e.g., emp_9876), this is what will appear in new files.
To fix this, we need to either:
Replace ${USER} with your name directly in the template, or
Override the ${USER} variable in Android Studio to point to your name (so all templates using ${USER} use your custom name).
Android Studio installed (version 4.0+ recommended; steps are similar across versions like Arctic Fox, Bumblebee, Chipmunk, etc.).
Basic familiarity with navigating Android Studio settings.
Step-by-Step Guide to Customize the Author Template#
Method 1: Edit the "File Header" Template Directly#
This method modifies the global "File Header" template, which is included in most new files (Java classes, Kotlin files, etc.). It’s quick and works for most cases.
At the top of the "File and Code Templates" window, select the Includes tab. This tab contains reusable template snippets, including the "File Header" (used in most file templates).
If you want your name to appear in all templates that use ${USER} (not just the File Header), override the ${USER} variable itself. This ensures consistency across all generated files (e.g., activities, fragments, services).
Possible Cause: You edited a project-level template instead of the global IDE template.
Fix: In the "File and Code Templates" window, check the "Scheme" dropdown (top-left). Select Default (to edit global templates) instead of Project (which only affects the current project).
Issue 2: Some Templates Still Show the Old Author#
Possible Cause: Certain file types (e.g., Activities, Fragments) use their own templates that don’t rely on the "File Header".
Fix:
Go to Settings > Editor > File and Code Templates > Templates tab.
Select the template for the problematic file type (e.g., Activity under "Android").
Look for ${USER} in the template and replace it with your name, or ensure the template includes the "File Header" (via #parse("File Header.java")).
Customizing the author template in Android Studio ensures your name (not an employee ID) appears in all new files, making collaboration smoother and code ownership clearer. Whether you edit the "File Header" directly or override the ${USER} variable globally, the process is straightforward and takes only a few minutes.
By following these steps, you’ll maintain professional, readable code headers that reflect your identity as a developer.