안드로이드 API 레벨 개요

안드로이드 버전별 모든 변경점은 공식문서를 참고할 것.
여기에는 내가 일하면서 겪은 사항들만 기록하려 한다.

14 (4.0.2 Ice Cream Sandwich) 이하

이 버전까지는 Facebook SDK에서 지원하지 않는다.

18 (4.3 Jelly Bean) 이하

이 버전까지는 Google Play service 및 Unity에서 지원하지 않는다.

20 (4.4W KitKat) 이하

빌드 에러: Cannot fit requested classes in a single dex file

원인

단일 dex 바이트코드 파일에서 참조 가능한 메소드 숫자는 65,536개로 제한되어 있다. API level 20 이하에서는 이 문제를 multidex 라이브러리를 implement하여 dex파일의 파티션을 나누는 방식으로 해결해야 한다. API level 21 이상에서는 런타임을 Dalvik에서 ART로 교체하여 multidex 라이브러리가 없어도 문제가 발생하지 않는다.

해결

  1. AndroidX 미사용시
android {
    compileSdkVersion 28
    buildToolsVersion '28.0.3'
    
    defaultConfig {
        minSdkVersion 19
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        multiDexEnabled true <- added
    }
    ...
}

dependencies {
  ...
  implementation 'com.android.support:multidex:1.0.3' <- added
  ...
}
  1. AndroidX 사용시
android {
    compileSdkVersion 28
    buildToolsVersion '28.0.3'
    
    defaultConfig {
        minSdkVersion 19
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        multiDexEnabled true <- added
    }
    ...
}

dependencies {
  ...
  implementation 'androidx.multidex:multidex:2.0.1' <- added
  ...
}

출처

23 (6 Marshmellow) 이상

  • 위험 권한(dangerous permission) 요청시 manifest에 명시하는 것에 추가로 런타임 중에 다이얼로그를 띄워서 유저에게 직접 권한을 요청해야 한다.

  • usesCleartextTraffic="true"AndroidManifest.xml에 명시해야 https 아닌 http 평문으로 통신할 수 있다.

  • Android App Links 기술 사용 가능 (AutoVerify="true")

24 (7 Nougat) 이상

directBootAware="true"AndroidManifest.xml에 명시해야 잠금 화면에 푸쉬 메시지 표시 가능

26 (8.0 Oreo) 이상

모든 알림 (notification) 에 채널 (안드로이드 UI상의 표기는 '카테고리') 을 지정해야 한다.
공식문서

30 (11 R) 이상

다른 앱과 상호작용하는 라이브러리를 사용시 AndroidManifest.xml에 queries로 명시해야 한다.
공식 문서

내가 다뤄본 라이브러리 중 해당되는 것은 다음과 같았다.

  • 커스텀탭스
  • 원스토어
  • 갤럭시 스토어
<manifest>
    <queries>
        <!-- for Custom Tabs service -->
        <intent>
            <action android:name=
                "android.support.customtabs.action.CustomTabsService" />
        </intent>

        <!-- for Onestore service -->
        <intent>
            <action android:name="com.onestore.ipc.iap.IapService.ACTION" />
        </intent>
        <intent>
            <action android:name="android.intent.action.VIEW" />
            <data android:scheme="onestore" />
        </intent>
        
        <!-- for Galaxy Store service -->
        <package android:name="com.sec.android.app.samsungapps" />
    </queries>
</manifest>

31 (12 S) 이상

PendingIntent 객체 생성시 파라미터 중 flag 란에 변경 가능 여부 (FLAG_MUTABLE or FLAG_IMMUTABLE) 를 명시해야 한다.

33 (13 Tiramisu) 이상

Notification을 표시하려면 새로운 동적 퍼미션 요청 필수

출처

Manifest상 권한은 FCM SDK (버전 23.0.6 이상) 에 이미 선언되어 있다.

// Declare the launcher at the top of your Activity/Fragment:
private val requestPermissionLauncher = registerForActivityResult(
    ActivityResultContracts.RequestPermission()
) { isGranted: Boolean ->
    if (isGranted) {
        // FCM SDK (and your app) can post notifications.
    } else {
        // TODO: Inform user that that your app will not show notifications.
    }
}

private fun askNotificationPermission() {
    // This is only necessary for API level >= 33 (TIRAMISU)
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
        if (ContextCompat.checkSelfPermission(this, Manifest.permission.POST_NOTIFICATIONS) ==
            PackageManager.PERMISSION_GRANTED
        ) {
            // FCM SDK (and your app) can post notifications.
        } else if (shouldShowRequestPermissionRationale(Manifest.permission.POST_NOTIFICATIONS)) {
            // TODO: display an educational UI explaining to the user the features that will be enabled
            //       by them granting the POST_NOTIFICATION permission. This UI should provide the user
            //       "OK" and "No thanks" buttons. If the user selects "OK," directly request the permission.
            //       If the user selects "No thanks," allow the user to continue without notifications.
        } else {
            // Directly ask for the permission
            requestPermissionLauncher.launch(Manifest.permission.POST_NOTIFICATIONS)
        }
    }
}

광고 ID 사용 권한 요청 필요

앱에서 광고 ID를 사용할 경우 Manifest에 권한을 선언해야 한다.

<uses-permission android:name="com.google.android.gms.permission.AD_ID"/>

또한 광고 ID 사용 여부와 관계없이 플레이스토어에 앱 출시 시 광고 ID 사용 여부를 명시해야 한다.
Firebase 사용시 firebase-bom 라이브러리에 해당 권한이 이미 선언되어 있으므로 광고 ID 사용 여부를 "예" 라고 명시해야 한다.

profile
유니티 게임 클라이언트 개발자를 꿈꾸는 뉴비

0개의 댓글

Powered by GraphCDN, the GraphQL CDN