메뉴 닫기
공지사항 : > 공지사항

[안드로이드] 안드로이드 12 (targetSdk 31) 이상 선언 시, 점검사항

작성자
관리자
작성일
2022.05.04 16:36
조회
7697


targetSdk31 이상, 선언시에는 안드로이드 정책상 변경점들이 다수 발생 하므로 충분히 숙지 후, 적용하시기 바랍니다.

1. AndroidManifest.xml 의 Intent-filter의 exported 명시적 선언

    Launcher Activity, Receiver 등 Intent-filter가 적용되는 경우

    https://developer.android.com/about/versions/12/behavior-changes-12?hl=ko#exported

첨부파일 : AndroidManifest.xml 참고 

2. PendingIntent 시용시, flag 적용 

   오류 사항 

 java.lang.IllegalArgumentException: com.morpheus.demo: Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent.

 조치 : 오류가 발생하는 코드를 추적하여, FLAG_IMMUTABLE or FLAG_MUTABLE 를 적용 

예시 :  FLAG_IMMUTABLE를 적용한 예시

   - 기존 

PendingIntent mPendingIntent = PendingIntent.getBroadcast(this, 0, alarmIntent, PendingIntent.FLAG_CANCEL_CURRENT);

  - 변경 

PendingIntent mPendingIntent = PendingIntent.getBroadcast(this, 0, alarmIntent, PendingIntent.FLAG_CANCEL_CURRENT | PendingIntent.FLAG_IMMUTABLE);


3. PendingIntent.getBroadcaste 사용 중지에 따라, PendingIntent.getActivity 를 사용하도록 비즈니스 로직 변경 검토

안드로이드 12 (targetSdk 31 이상) 에서는 service 나 BroadCastReceiver 를 통한 앱 실행에 제한이 있습니다.
https://developer.android.com/about/versions/12/behavior-changes-12#notification-trampolines

  라이브러리 버전 및 적용 방식에 따라, 샘플 참고

   https://developer.uracle.co.kr/reference/


4. Push 라이브러리 교체 

   - 방법 1 : 푸시 5.1 라이브러리를 계속 이용하는 방법

       아래 링크를 참고하여, jobdispatcher 라이브러리 교체 필요

      https://developer.uracle.co.kr/faq/?uid=288&mod=document&pageid=1

  - 방법2 : 푸시 5.2 적용 : 마이그레이션 가이드

    UPNS  연동 시  :  https://wiki.uracle.co.kr/push/client/reference/5-1_to_5-2_migration

    FCM 연동 시 : https://wiki.uracle.co.kr/push/client/reference/Migration_FCM_5_1_to_5_2

  - 푸시 5.2 신규 적용 가이드 

    https://wiki.uracle.co.kr/ko/push/client#android-ver52