본문 바로가기
Android/Exceptions

안드로이드 12, android:exported ::: Execution failed for task ':app:checkDebugAarMetadata'. minCompileSdk (31)

by featherwing 2021. 11. 4.
반응형

App을 빌드하는 과정에서 아래와 같은 오류로 앱이 빌드되지 않는 경우가 있습니다.

 

 

Execution failed for task ':app:checkDebugAarMetadata'.

 

해당 failded를 좀 더 자세히 확인하면 아래와 같은 메시지를 확인할 수 있습니다.

One or more issues found when checking AAR metadata values:

The minCompileSdk (31) specified in a
dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)
is greater than this module's compileSdkVersion (android-30).
Dependency: androidx.browser:browser:1.4.0.

일부 module에서 minCompileSdk이 31이어야 한다는 내용의 메시지입니다.

제 경우에는 androidx.browser:browser:1.4.0이 SdkVersion 31을 필수적으로 요구하는것으로 보입니다.

 

 


 

 

해결방법을 먼저 말씀드리면 아래와 같습니다.

1. app단의 build.gradle에서 compileSdkVersion 31, targetSdkVersion 31 이상으로 변경. 

2. 1번 조건일 경우 manifests의 activity, receiver 등과 같은 Component가 Intent-filter를 가지고 있을 경우  android:exported="true"  android:exported="false" meta-data를 명시적으로 선언.

 

 

1. app단의 build.gradle에서 compileSdkVersion 31, targetSdkVersion 31 이상으로 변경 

해당 내용에 따라 app단의 build.gradle에서 compileSdkVersion 31, targetSdkVersion 31 이상으로 변경해줍니다. 

 

 

 

 

2. manifests의 activity, receiver 등과 같은 Component가 Intent-filter를 가지고 있을 경우에  android:exported="true" android:exported="false" meta-data를 명시적으로 선언.

 

1번에서 SdkVersion을 수정한 이후에 빌드를 시도하면 동일한 오류가 발생하며 아래와 같은 메시지를 추가로 확인할 수 있습니다.

> 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 개발자  |  Android Developers

Declares an activity (an Activity subclass) that implements part of the application's visual user interface. All activities must be represented by {@code } elements in the manifest file. Any that are not declared there will not be seen by the system…

developer.android.com

 

해당 개발자 문서의 내용은 android:exported meta-data에 관한 부분입니다.

 

exported 속성은 해당 meta-data가 적용된 앱의 부분이 외부 응용 프로그램에 의해서 실행될 수 있는지의 유무를 설정하는 내용입니다.

 

예를들어 인텐트로 앱을 실행하기 위해서는 android:exported="true"가 선언해야 합니다.

android:exported="false"를 선언하게 된다면, 외부 앱이 특정 액티비티를 실행할 때 

ActivityNotFoundException이 발생하게 되므로,

 

ActivityNotFoundException  |  Android Developers

 

developer.android.com

외부앱과 상호작용이 필요한 부분에는 true를 선언해주어야 합니다.

 

기존의 경우에는 exported="true"가 기본값으로 자동적으로 적용되었기 때문에

외부에서 실행이 불가능하도록 만들어야할 때만 exported="false"를 선언해주면 되었지만 

 

SdkVersion31(Android 12) 이후를 타겟팅하는 앱부터는

intent-filter를 선언한 Component에는 반다시 exported를 명시적으로 선언해야 하도록 변경되었습니다.

 

BroadcastReceiver등이 아니더라도, 앱에서는 보통 아래와 같이 런쳐와 메인 인텐트를 부여하는데 

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

기존에는 위처럼 써도 exported="true"가 자동적으로 적용되었으나 SdkVersion31(Android 12) 이후를 타겟팅하는 앱부터는 아래와 같이 명시적으로 선언해주어야 합니다.

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

intent-filter를 사용하지 않는 Component는 exported를 명시적으로 선언해주지 않아도 그대로 사용할 수 있습니다.

 

해당 부분을 변경해주시면 오류를 해결할 수 있습니다.

 

 

 

reference :

1. The minCompileSdk (31) specified :: StackOverflow

 

The minCompileSdk (31) specified

The minCompileSdk (31) specified in a dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties) is greater than this module's compileSdkVersion (android-30). Dependency:

stackoverflow.com

2. Manifest merger failed : Apps targeting Android 12 - Android Studio Error [duplicate] :: StackOverflow

 

The minCompileSdk (31) specified

The minCompileSdk (31) specified in a dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties) is greater than this module's compileSdkVersion (android-30). Dependency:

stackoverflow.com

3. How to resolve this error The minCompileSdk (31) specified in a dependency's AAR metadata in native java/kotlin? :: StackOverflow

 

How to resolve this error The minCompileSdk (31) specified in a dependency's AAR metadata in native java/kotlin?

The minCompileSdk (31) specified in a dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties) is greater than this module's compileSdkVersion (android-30). Dependency:

stackoverflow.com

 

반응형

댓글