google_maps_flutter broken with Flutter version 2.10.2
Update your android -> app -> build.gradle file with this code from android
to above than buildTypes
. compileSdkVersion will be the android version on which the app is being compiled. minSdkVersion
is for lowest android version that your app can be compatible with. Mostly now the packages demand 21 as the minSdk so set it to 21 but with 20 it should be working now too because you was missing multidex too and that contains some code which is used to run the app.
android {
compileSdkVersion 30
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
defaultConfig {
applicationId "com.example.ticket_distribution_app"
minSdkVersion 21
multiDexEnabled true
targetSdkVersion 30
versionCode 1
versionName "1.0.0"
}
Note: Make sure if you are using flutter 2.10.0-2.10.2 then change compileSdkVersion
to 31
Riley-Howley
Updated on November 26, 2022Comments
-
Riley-Howley over 1 year
I have used google_maps_flutter in my flutter application but when I updated the flutter to the version 2.10.2 this has broken the version.
The plugin google_maps_flutter requires a higher Android SDK version. │ │ Fix this issue by adding the following to the file │ │ C:\Users\howle\Documents\GitHub\TicketDistribution\android\app\build.gradle: │ │ android { │ │ defaultConfig { │ │ minSdkVersion 20 │ │ } │ │ } │ │ │ │ Note that your app won't be available to users running Android SDKs below 20. │ │ Alternatively, try to find a version of this plugin that supports these lower versions of the │ │ Android SDK.
I followed the steps of changing the version but it hasnt seemed to work, So I was wondering if any other devs are facing this issue or have a solution?
I will put my build.gradle, and localproperties file below. app/build.gradle
def localProperties = new Properties() def localPropertiesFile = rootProject.file('local.properties') if (localPropertiesFile.exists()) { localPropertiesFile.withReader('UTF-8') { reader -> localProperties.load(reader) } } def flutterRoot = localProperties.getProperty('flutter.sdk') if (flutterRoot == null) { throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") } def flutterVersionCode = localProperties.getProperty('flutter.versionCode') if (flutterVersionCode == null) { flutterVersionCode = '1' } def flutterVersionName = localProperties.getProperty('flutter.versionName') if (flutterVersionName == null) { flutterVersionName = '1.0' } apply plugin: 'com.android.application' apply plugin: 'kotlin-android' apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" android { compileSdkVersion flutter.compileSdkVersion compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } defaultConfig { minSdkVersion 20 } 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.example.ticket_distribution_app" minSdkVersion flutter.minSdkVersion targetSdkVersion flutter.targetSdkVersion versionCode flutterVersionCode.toInteger() versionName flutterVersionName } 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.debug } } } flutter { source '../..' } dependencies { implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" }
local.properties
sdk.dir=C:\\Users\\howle\\AppData\\Local\\Android\\sdk flutter.sdk=C:\\flutter flutter.buildMode=debug flutter.versionName=1.0.0 flutter.versionCode=1 flutter.minSdkVersion=20 flutter.targetSdkVersion=20
Cheers In advance devs.
-
Will Hlas about 2 yearsTry changing
compileSdkVersion
andminSdkVersion
to 21 fromapp/build.gradle
and see if that works. -
Riley-Howley about 2 yearsI tried that but it still gave me the error. Thanks for trying!
-
Will Hlas about 2 yearsOh shoot I meant for you to change compileSdkVersion to 30 or 31! Looks like you got it working though :D
-
-
Riley-Howley about 2 yearsCheers, I did what you said and it solved my issue. Then I updated my kotlin to a newer version and now hoping it compiles thankyou very much!
-
Ahmad Hassan about 2 yearsGlad I helped you. Sorry I missed the kotlin part I forgot to mention that but anyway good luck with your application!