Sobes.tech
Junior — Middle

Can you explain the purpose and structure of the AndroidManifest.xml file in Android projects?

sobes.tech AI

Answer from AI

The AndroidManifest.xml file is the main configuration file of an Android application, describing its structure and components to the Android system.

Purpose:

  • Declare application components: Activities, Services, BroadcastReceivers, ContentProviders.
  • Define permissions needed by the app.
  • Specify minimum and target SDK versions.
  • Configure themes, icons, intent filters, and other metadata.

Structure:

  • Root <manifest> element with package and xmlns attributes.
  • Inside <application>, components and general settings are described.
  • Each component (e.g., <activity>) can contain <intent-filter>s indicating what actions it handles.

Example:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.app">

    <uses-permission android:name="android.permission.INTERNET" />

    <application
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name">

        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

    </application>
</manifest>

In Flutter projects, AndroidManifest.xml is located at android/app/src/main and is used for configuring the native part of the app.