Reputation: 1
I am developing a Flutter app and need to ensure it targets Android 14 (API level 34) as required by the Google Play Console. Here is my current android/app/build.gradle configuration:
plugins {
id "com.android.application"
id "kotlin-android"
id "dev.flutter.flutter-gradle-plugin"
}
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '8'
}
def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.6.0'
}
def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}
android {
compileSdkVersion 34
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 {
minSdkVersion 21
targetSdkVersion 34
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 {
signingConfig signingConfigs.release
}
}
}
flutter {
source '../..'
}
dependencies {
implementation 'com.google.android.material:material:1.0.0'
implementation "org.jetbrains.kotlin:kotlin-stdlib:1.9.23"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.10"
}
Despite setting compileSdkVersion and targetSdkVersion to 34, the Google Play Console still indicates that my app does not target Android 14.
What additional steps or configurations do I need to ensure my Flutter app targets Android 14 (API level 34)?
What I have tried:
Ensuring the compileSdkVersion and targetSdkVersion are set to 34. Running flutter clean and flutter pub get. Rebuilding the APK and AAB files. Any guidance or suggestions would be greatly appreciated. Thank you!
I expected that setting compileSdkVersion and targetSdkVersion to 34 would make my app target Android 14 (API level 34). After rebuilding the app, I anticipated that the Google Play Console would recognize the app as targeting Android 14.I have done that in my last release but still I am getting that message on google play console.
Upvotes: 0
Views: 1224
Reputation: 51
I think minSdkVersion should be set to 34, not compileSdkVersion or targetSdkVersion
android {
...
targetSdkVersion flutter.targetSdkVersion
...
defaultConfig {
...
minSdkVersion 34
...
}
...
}
It can be useful to run flutter create
in temporary location to see what the latest defaults are.
It should also be safe to run flutter create
in your current project as an update.
Upvotes: 1