Android Naming Rules

Where can I find naming rules for Android resources? I found out due to compilation errors that I should use the characters inside [a-z0-9._], but I also have an error with the image named 401.png. When using this in my layout using

@drawable/401 

I get the following compilation error:

 invalid VariableDeclaratorId 

I cannot find these rules in the document, and I would like to know all of them before naming my files.

thanks

+6
source share
6 answers

The rules are the same as for Java identifiers , since each resource must have a corresponding ID field generated in the R.java file.

+6
source

The number is not allowed, since the first char of the resource is also not the capital of the last

+2
source

It is worth noting that: "File-based file names should contain only lowercase az, 0-9, or underscores." (quoted from compilation error code).

+2
source

Your convention is true, except that you cannot start file names with a number.

0
source

Resource naming rules are the same as for variables, except for case sensitivity. In your case, the problem is that the first character is a number.

0
source

This is a Java rule, not an Android-only rule. Name each element a starting letter, and you will be right.

0
source

Source: https://habr.com/ru/post/887713/


All Articles