android12를 타겟팅해야하는 경우, AndroidManifest.xml 파일에서 activities, services, receivers 등에 android:exported 를 설정해야한다.
<activity
android:name=".QrCodeScanActivity"
android:screenOrientation="portrait"
android:stateNotNeeded="true"
android:windowSoftInputMode="stateAlwaysHidden"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
해당코드에서 android:exported="true" 속성이 없으면
Manifest merger failed : android:exported needs to be explicitly specified for element <>. 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.
와 같은 에러가 발생한다.
따라서 exported 속성을 activity 태그 안에 지정해야한다.
단, intent-filter 속성을 사용하는 acitivity 일 경우 exported 옵션을 true 로 설정해야한다.
다른 애플리케이션 앱과 상호작용할 계획이 없다면 exported 옵션을 false 로 지정한다 .
android12 버전부터는 exported 옵션을 명시적으로 manifest 파일에 지정해야한다.
728x90