본문 바로가기
안드로이드

[Android Studio] Android 12 타겟팅 시 Manifest merger failed / android:exported

by 고간디 2022. 2. 14.

앱을 만들어 보고 싶어서 안드로이드 스튜디오를 통해서 공부하고 있었는데 오류가 발생했다


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

위와 같은 코드를 적었는데 activity에 빨간 밑줄이 그어지며 해당 부분에서 오류가 발생했다


Manifest merger failed : android:exported needs to be explicitly specified for <activity>. Apps targeting Android 12 and higher are required to specify an explicit value for `android:exported` when the corresponding component has an intent filter defined. See https://developer.android.com/guide/topics/manifest/activity-element#exported for details.

빌드 프로세스 내용입니다
이유를 찾아보니 Android 12를 타겟팅하는 경우에는 AndroidManifest.xml 파일에서 android:exported를 설정해주어야 한다고 합니다
기존에는 설정하지 않아도 기본으로 적용됐으나 Android 12 부터는 필수로 지정해주어야 합니다


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

이렇게 android:exported를 설정해두고 값을 false로 지정하니 해결되었습니다

(그런데 false로 지정한 상태에서 AVD Manager를 사용하니 앱이 열리지 않길래 true로 바꿔보니 정상 작동됐습니다)

728x90
반응형

댓글