Mike G
Mike G

Reputation: 4959

How is R.id generated in Android platform?

Can I assume that R.id file will be present in every android project?

Or is this specific to certain dev environments?

Upvotes: 1

Views: 588

Answers (3)

MByD
MByD

Reputation: 137342

It is generated by the aapt tool. From android site:

Once you provide a resource in your application (discussed in Providing Resources), you can apply it by referencing its resource ID. All resource IDs are defined in your project's R class, which the aapt tool automatically generates.

Upvotes: 1

Ben Weiss
Ben Weiss

Reputation: 17932

The class R is essential to all Android apps and will be automatically generated if your project does not contain errors. So, it's not specific to any build environment other than android itself.

Upvotes: 1

Richard Ev
Richard Ev

Reputation: 54117

It gets autogenerated by the compiler; you can safely assume it will always exist.

Check the documentation:

A project's R.java file is an index into all the resources defined in the file.

You use this class in your source code as a sort of short-hand way to refer to resources you've included in your project.

This is particularly powerful with the code-completion features of IDEs like Eclipse because it lets you quickly and interactively locate the specific reference you're looking for.

Upvotes: 3

Related Questions