오류 내용

폰을 안드로이드12로 업데이트 한 후 몇개의 앱이 실행이 되지 않는다.

 

 

안드로이드 스튜디오에서 수행해보니 아래와 같은 오류가 출력된다

Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent.
Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE if some functionality depends on the PendingIntent being mutable, e.g. if it needs to be used with inline replies or bubbles.

 

 

오류 해결

안드로이드12(targetsdk 31)에서 발생하는 오류인데, dependencies에 한줄만 추가해주면 된다.

build.gradle

dependencies {
    ...
    implementation'androidx.work:work-runtime-ktx:2.7.0'
    ...
}

 

시도했던 방법

오류 로그에 PendingIntent가 있어서 검색을 했더니 아래와 같이 수정하면 된다고 한다. 내 경우 해결책은 아니었다.

val intent = PendingIntent.getActivity(this, 0, customIntent, 0) // fail
val intent = PendingIntent.getActivity(this, 0, customIntent, PendingIntent.FLAG_IMMUTABLE) // success