Layout File Name Not in snake_case

ID

java.android_layout_file_name

Severity

info

Remediation Complexity

trivial

Remediation Risk

medium

Remediation Effort

low

Resource

Naming Convention

Language

Java

Tags

android, naming

Description

Reports Android layout XML files whose file name does not follow the snake_case.xml convention (lowercase letters, digits and underscores only).

Rationale

Android Studio, AAPT and many code generators (data-binding, view-binding) rely on the snake_case convention when deriving generated R-class identifiers and binding class names. Deviations cause inconsistent generated identifiers, break code review tooling that uses the file name as a heuristic, and stand out in mixed teams.

res/layout/MainActivity.xml      <-- Bad (PascalCase)
res/layout/main-activity.xml     <-- Bad (dash)
res/layout/mainActivity.xml      <-- Bad (camelCase)
res/layout/main_activity.xml     <-- Good

Remediation

Rename the file to use lowercase letters, digits and underscores. Make sure to update every reference in code (R.layout.main_activity, setContentView(R.layout.…)) and in other layout files (<include layout="@layout/…"/>).