[Android] AndroidManifest

강승구·2022년 5월 6일
0

AndroidManifest.xml

AndroidManifest.xml은 앱의 필수 구성요소로 안드로이드 시스템이 앱의 코드를 실행하기 전에 확보해야 하는 앱에 대한 필수 정보를 시스템에 제공하는 목록이다.

AndroidManifest.xml에서는 아래 3가지가 정의되며, 정의되지 않은 권한이나 구성요소를 앱 구동 시 사용할 수 없다.

  • 앱의 고유한 식별자인 패키지명,
  • 안드로이드 앱에서 필요한 권한,
  • 안드로이드 구성요소(Activity, Service, Broadcast Recevicer, ContentProvider)

AndroidManifest.xml 파일에서 정의되지 않으면 앱의 구성요소로 인식이 되지 않아 사용할 수 없게 된다.

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.myapplication">

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/Theme.MyApplication">
        <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>



기본 설정

<?xml version="1.0" encoding="utf-8"?>

이 파일이 XML 문서임을 선언하는 문장
version은 XML의 버전을 의미하고 encoding은 이 파일에 적용되는 인코딩 방식이 무엇인지를 의미한다.


manifest

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

xmlns:android = "http//schemas.android.com/apk/res/android"

xmlns:android는 android라는 'namespace를 선언한다' 는 뜻이다.
여기서 namespace는 고유한 URI를 의미한다.

packge = "com.example.rp3_cong_baemin"

이 정보로 앱을 식별한다.
gradle 파일에 설정된 application Id의 값과 같다.


<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.dailycarelab.fitodo">
	
    //권한 요청 부분
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.CAMERA" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    
    ...
    
</manifest>

manifest 내부에서는 앱의 권한도 설정해줄 수 있다.
uses-permission 블록에 android:name 값을 주어 선언해야 한다. android:name값에는 필요한 권한을 입력한다.



application

application은 앱을 정의하는 공간이다.
이곳에서는 앱의 어플리케이션 파일이 정의된 곳, 앱의 아이콘, 앱의 명칭, 앱의 테마, 구성요소를 정의한다.

<application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/Theme.Rp3congbaemin">
        <activity android:name=".SubActivity"></activity>
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>
</application>

테마

android:allowBackup = "true"

애플리케이션이 백업 및 복원 인프라에 참여하도록 허용할지 여부
이 속성을 false로 설정하면 모든 애플리케이션 데이터가 adb를 통해 저장되는 전체 시스템 백업에 의해서도 애플리케이션의 백업 또는 복원이 수행되지 않는다. 이 속성의 기본값은 true이다.

android:icon = "@mipmap/ic_launcher"

전체 애플리케이션의 아이콘 및 애플리케이션의 각 구성요소의 기본 아이콘

android:label = "@string/app_name"

전체 애플리케이션을 나타내는, 사용자가 읽을 수 있는 라벨 및 애플리케이션의 각 구성요소의 기본 라벨

android:roundIcon = "@mipmap/ic_launcher_round"

둥근 형태의 아이콘을 설정하는 속성

android:supportsRtl = "true"

애플리케이션이 오른쪽에서 왼쪽(RTL) 레이아웃을 지원하는지 여부를 선언한다.

android:theme = "@style/Theme.Rp3congbaemin">

애플리케이션의 모든 활동의 기본 테마를 정의하는 스타일 리소스의 참조

구성요소 (컴포넌트)

application 내부에는 안드로이드 4대 컴포넌트라 불리는 Activity, Service, Broadcast Recevier, Content Provider를 선언하기도 한다.
만약 이곳에 구성요소가 선언되어 있지 않다면 앱에서 구성요소는 실행되지 않는다.

profile
강승구

0개의 댓글