3
3

More than 1 year has passed since last update.

Flutter Android API レベルを上げる方法

Last updated at Posted at 2023-08-28

はじめに

Screenshot 2023-08-28 at 19.13.46.png
Androidで公開しているアプリに対して、以下のような警告が届いた。

古いバージョンの Android を対象にしているアプリが 2 個あることが判明しました。Google Play では、ユーザーに安全で保護されたエクスペリエンスを提供するため、すべてのアプリについて 2023/08/31までに対象 API レベル要件に準拠することを義務付けています。

アプリを更新して Android 13 を対象にしないといけないようです:sweat:

ターゲットとなるAndroidのOSバージョン(APIレベル)を変更する

android/app/build.gradle
android {
    compileSdkVersion 33 // // 33に変更!
    ndkVersion flutter.ndkVersion

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    kotlinOptions {
        jvmTarget = '1.8'
    }

    sourceSets {
        main.java.srcDirs += 'src/main/kotlin'
    }

    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "com.sample.app"
        // You can update the following values to match your application needs.
        // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration.
        minSdkVersion flutter.minSdkVersion
        targetSdkVersion 33 // 33に変更!
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
    }

    signingConfigs {
        release {
            keyAlias keystoreProperties['keyAlias']
            keyPassword keystoreProperties['keyPassword']
            storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
            storePassword keystoreProperties['storePassword']
        }
    }

    buildTypes {
        release {
            // TODO: Add your own signing config for the release build.
            // Signing with the debug keys for now, so `flutter run --release` works.
            signingConfig signingConfigs.release 
        }
    }
}

compileSdkVersiontargetSdkVersionを33に変更しましょう。

初期値では以下のようになってるかと思いますが、

defaultConfig {
    targetSdkVersion flutter.targetSdkVersion
    ...
  }

flutter.targetSdkVersionを消して「33」みたいな数値を直接入れても問題ないようです!

あとはバージョンを上げて公開すればOKです:v:

Screenshot 2023-08-28 at 21.00.24.png
かなり強めの警告が出てるので早めに対処しましょう・・・・

3
3
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
3
3