cyberangles blog

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:

  1. Directly editing the file header template to replace the employee number with your name.
  2. 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.

2026-01

Table of Contents#

  1. Understanding the Author Template in Android Studio
  2. Prerequisites
  3. Step-by-Step Guide to Customize the Author Template
  4. Verifying the Changes
  5. Troubleshooting Common Issues
  6. Conclusion
  7. References

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).

Prerequisites#

  • 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.

Step 1: Open Android Studio Settings#

  • Windows/Linux: Go to File > Settings (or press Ctrl + Alt + S).
  • macOS: Go to Android Studio > Preferences (or press Cmd + ,).

Step 2: Navigate to File Templates#

In the left sidebar of the Settings/Preferences window:

  • Expand Editor (under "IDE Settings").
  • Select File and Code Templates.

Step 3: Access the "Includes" Tab#

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).

Step 4: Edit the "File Header" Template#

  • In the list of includes, select File Header (it may be under the "Android" or "Default" group, depending on your setup).
  • The template editor will display the current header. A typical default header looks like this:
    /**  
     * Created by ${USER} on ${DATE}.  
     */  
    Or for Kotlin:
    /**  
     * Created by ${USER} on ${DATE}.  
     */  
  • Replace ${USER} with your name (e.g., John Doe). For example:
    /**  
     * Created by John Doe on ${DATE}.  
     */  

Step 5: Save the Changes#

Click Apply (bottom-right) then OK to save the template.

Method 2: Override the USER Variable Globally#

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).

Step 1: Open Android Studio Settings#

Same as Method 1: File > Settings (Windows/Linux) or Android Studio > Preferences (macOS).

Step 2: Define a Custom USER Variable#

  • In the left sidebar, expand Appearance & Behavior > System Settings.
  • Select Passwords (yes, this is where IDE variables are sometimes managed—confusing, but correct!).
  • Click the Variables button (near the bottom of the window).

Step 3: Add the USER Variable#

  • In the "Variables" dialog, click the + (Add) button.
  • For "Name", enter USER.
  • For "Value", enter your name (e.g., Jane Smith).
  • Click OK to save the variable.

Step 4: Confirm the Change#

Android Studio will now use your custom USER value instead of the system username for all templates that reference ${USER}.

Verifying the Changes#

To confirm your author template is updated:

  1. Create a new file: Right-click on a package in the Project pane (e.g., app > src > main > java > com.yourpackage).

  2. Select New > Java Class or New > Kotlin File/Class.

  3. Enter a name (e.g., MyNewClass) and click OK.

  4. Check the header: Open the new file. The header should now display your name instead of the employee ID. For example:

    /**  
     * Created by Jane Smith on 2024-03-15.  
     */  
    public class MyNewClass {  
    }  

Troubleshooting Common Issues#

Issue 1: Changes Not Reflecting in New Files#

  • 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:
    1. Go to Settings > Editor > File and Code Templates > Templates tab.
    2. Select the template for the problematic file type (e.g., Activity under "Android").
    3. 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")).

Issue 3: USER Variable Override Not Working#

  • Possible Cause: The USER variable may be cached.
  • Fix: Restart Android Studio to apply the new variable.

Conclusion#

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.

References#