13

Can anybody explain me in simple words what is the use of Manifest file and R.java file in android.

Why do we need these files while making an application?

1
  • 7
    Please go ahead and accept answers for your previous questions... We like to help you here at SO, so please take the time and reward those who do. Feb 11, 2011 at 8:37

6 Answers 6

11

check this link,

http://developer.android.com/guide/topics/manifest/manifest-intro.html

Manifest

Every application must have an AndroidManifest.xml file (with precisely that name) in its root directory. The manifest presents essential information about the application to the Android system, information the system must have before it can run any of the application's code

R.Java

It will have identifier for all resource used in our project

thank you.

1
  • ya go to hello world example in developer.android.com you can get good knowledge abt android programming . Feb 11, 2011 at 8:46
7

Manifest file:

  1. It is a declaration file.
  2. Here only Which activity should start first, that has been declared.
  3. It declares which permissions the application must have.
  4. It also declares the permissions that others are required to have in order to interact.
  5. It declares the minimum level of the Android API.
  6. It lists the libraries that the application must be linked.
  7. All the component should declared here.
  8. The components are activities, services, broadcast receivers, and content providers.

R.java file:

  1. It is an auto-generated file by aapt (Android Asset Packaging Tool) that contains resource IDs for all the resources of res/ directory.
  2. If you create any component in the activity_main.xml file, id for the corresponding component is automatically created in this file.
  3. This id can be used in the activity source file to perform any action on the component.
4

Every application must have an AndroidManifest.xml file (with precisely that name) in its root directory. The manifest presents essential information about the application to the Android system, information the system must have before it can run any of the application's code.

Check the following link

http://developer.android.com/guide/topics/manifest/manifest-intro.html

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.

Check the following link

http://developer.android.com/resources/tutorials/hello-world.html

0

In short terms Manifest provide the basic information of the application to Android Operating system.

For example say you have a feature in your app that scans a QR code which requires your app to access camera that won't work until unless you get the consent of the user to access their's phone camera which is done by runtime permissions.These permissions needs to be defined in the Manifest file for Android OS to know that this app will be using something related to camera of user's phone.

  1. The manifest file describes essential information about your app to the Android build tools, the Android operating system, and Google Play.
  2. The permissions that the app needs in order to access protected parts of the system or other apps.
  3. The hardware and software features the app requires.
0

The manifest declares anything that the operating system needs to know about your application.

You declare what permissions the OS will grant to your app when it executes.

You will also declare package information about your app. By doing that the OS will know what applications are installed.

Finally, you will declare custom implementations of the Foud Application Components (Activity, Service, BroadcstReceiver and ContentProvider classes) you have made.

You see, your application, any activities and services are not created by you. They are constructed by the OS through intents on behalf of your app. Likewise, all BroadcastReceivers need to be registered at the manifest, so the OS knows what application's receivers are registered to receive a broadcast, so it notifies them. Finally all ContentProviders must also be declared in the manifest so other applications can register to be provided content by your content provider.

In other words, in the manifest you put everything that the OS needs to know about your app in order to execute it and manage its components. Infact, anything you cannot access or declare directly by code, and you need the OS to take care of it...

0

I think it is a good idea for you to read through the Android Hello World. Both AndroidManifest and R.java are explained.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.