LoginSignup
37
11

More than 1 year has passed since last update.

compileSdk・minSdk・targetSdkの違い(Android)

Last updated at Posted at 2021-08-19

はじめに

compileSdkVersionminSdkVersiontargetSdkVersion の違いがいつもわからなくなるため、まとめることにします。

注意

ここからは末尾の Version を省略します。

各プロパティの違い

各プロパティの違いを紹介します。

compileSdk

compileSdkVersion specifies the Android API level Gradle should use to compile your app. This means your app can use the API features included in this API level and lower.

compileSdkVersionは、Gradleがアプリをコンパイルする際に使用するAndroid APIレベルを指定します。これは、アプリがこのAPIレベル以下に含まれるAPI機能を使用できることを意味します。

引用: https://developer.android.com/studio/build

要はコンパイルに使うSDKバージョンです。
新しい機能を使えるようにするため、基本的には現時点での最新を指定します。

minSdk

Defines the minimum API level required to run the app.

アプリの実行に必要な最低限のAPIレベルを定義します。

引用: https://developer.android.com/studio/build

要はアプリの最低OSバージョンです。
古いOSをサポートする場合、こちらの値を小さくします。

targetSdk

Specifies the API level used to test the app.

アプリのテストに使用するAPIレベルを指定します。

引用: https://developer.android.com/studio/build

公式ドキュメントの説明のみだとわからなかったのですが、Twitterで教えていただきました。

要はアプリを動作させるAPIレベルを指定します。
compileSdk と同じく基本的には現時点での最新を指定すればいいですが、例えばAndroid 12(APIレベル 31 )対応が完了していない場合、 targetSdk30 に指定すればAndroid 12でも11のように振る舞う、ということです。

おわりに

公式ドキュメントのコメントを読むだけではあまりわかりませんでしたが、何となく理解することはできました。

参考リンク

37
11
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
37
11