Use of Configuration APKs while still targeting pre lollipop devices

前端 未结 3 1405
眼角桃花
眼角桃花 2021-01-20 14:56

When developing for Instant Apps the use of Configuration APKs (https://developer.android.com/topic/instant-apps/guides/config-splits.html) offers useful option for cutting

3条回答
  •  滥情空心
    2021-01-20 15:17

    Instant apps are only supported in API 21+ devices (link), older devices will only support full apk.

    The better approach is to define different minSdk based on your module, like:

    You can take a look at Google's analytics sample on GitHub

    Project's gradle

    ext {
        buildTools = '26.0.2'
        compileSdk = 26
        minSdk = 15
        minSdkInstant = 21
        versionCode = 1
        versionName = '1.0'
        supportLib = '26.1.0'
        firebaseVer = '10.2.4'
        instantAppsVer = '1.0.0'
    }
    

    Base gradle

    android {
        compileSdkVersion rootProject.compileSdk
        buildToolsVersion rootProject.buildTools
        baseFeature true
        defaultConfig {
            minSdkVersion rootProject.minSdk
            targetSdkVersion rootProject.compileSdk
            versionCode rootProject.versionCode
            versionName rootProject.versionName
        }
        buildTypes {
            release {}
        }
    }
    

    Installed gradle

     defaultConfig {
            applicationId "com.example.android.instant.analytics"
            minSdkVersion rootProject.minSdk
            targetSdkVersion rootProject.compileSdk
            versionCode rootProject.versionCode
            versionName rootProject.versionName
    
        }
    

    Instant gradle

    android {
        defaultConfig {
            minSdkVersion rootProject.minSdkInstant
        }
    }
    

提交回复
热议问题