rokkonet

PC・Androidソフトウェア・アプリの開発・使い方に関するメモ

android開発 sdkのバージョン管理

2021 Jun. 26.

androidプログラミングにおいては、compileSdkVersion・minSdkVersion・targetSdkVersion・インストール先のandroidバージョンを確認すること。


compileSdkVersion・minSdkVersion・targetSdkVersionは(Projectではなく)Moduleのbuild.gradleファイルに書き込む


出典ページ  [Android]ビルドの設定ファイル(build.gradle)に登場する色んなバージョンの違い(compileSdkVersion / buildToolsVersion / minSdkVersion / targetSdkVersion) | プログラミング挫折撲滅プロジェクト・みんなのプログラミング by Telulu LLC(FlutterでiOS/Androidスマホアプリ開発)

minSdkVersion <= targetSdkVersion <= compileSdkVersion


minSdkVersion

アプリがインストールできる端末の最低のAPI

targetSdkVersion

アプリをテストするときに設定するAPIレベル(Androidのバージョン)

compileSdkVersion

コンパイル時に使うsdkのバージョン

build.gradleの例
plugins {
    id 'com.android.application'
    id 'kotlin-android'
}

android {
    compileSdkVersion 30
    buildToolsVersion "30.0.3"

    defaultConfig {
        applicationId "MY.PACKAGE.APPLICATION"
        minSdkVersion 24
        targetSdkVersion 30
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    kotlinOptions {
        jvmTarget = '1.8'
    }
}


上記設定におけるインストール端末例

androidバージョン7(APIレベル24)
androidバージョン10(APIレベル29)