How to Change Android Minsdkversion in Flutter Project

How to change Android minSdkVersion in flutter project

It is indeed possible to increase minSdkVersion, but it took me way too much time to find it out because google searches mostly yields as result discussions about the absolute minimum Sdk version flutter should be able to support, not how to increase it in your own project.

Like in an Android Studio project, you have to edit the build.gradle file. In a flutter project, it is found at the path ./android/app/build.gradle.

The parameter that needs to be changed is, of course, minSdkVersion 16, bumping it up to what you need (in this case 19).

defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.projectname"
minSdkVersion 19 //*** This is the part that needs to be changed, previously was 16
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}

Seems obvious now, but took me long enough to figure it out on my own.

Android minSdkVersion with Flutter(v2.8.1)

Add these lines in your android/local.properties

sdk.dir=/Users/{username}/Library/Android/sdk
flutter.sdk=/Users/{username}/Developer/flutter
flutter.buildMode=debug
flutter.versionName=1.0.0
flutter.versionCode=1

flutter.minSdkVersion=21 // new
flutter.targetSdkVersion=30 // new
flutter.compileSdkVersion=30 // new

then in your android/app/build.gradle replace these three lines

    minSdkVersion localProperties.getProperty('flutter.minSdkVersion').toInteger()
targetSdkVersion localProperties.getProperty('flutter.targetSdkVersion').toInteger()
versionCode flutterVersionCode.toInteger()

Set Android minSdkVersion for Flutter & Pub

Just assign your required SDK versions Like below. this will solve your compile error.

defaultConfig {
minSdkVersion 31
targetSdkVersion 31
}

or you can change flutter.minSdkVersion and flutter.targetSdkVersion directly from flutter>packages>Flutter_tools>gradle>flutter.gradle
https://stackoverflow.com/a/71440248/10936691

How to change Android minSdkVersion in flutter project

It is indeed possible to increase minSdkVersion, but it took me way too much time to find it out because google searches mostly yields as result discussions about the absolute minimum Sdk version flutter should be able to support, not how to increase it in your own project.

Like in an Android Studio project, you have to edit the build.gradle file. In a flutter project, it is found at the path ./android/app/build.gradle.

The parameter that needs to be changed is, of course, minSdkVersion 16, bumping it up to what you need (in this case 19).

defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.projectname"
minSdkVersion 19 //*** This is the part that needs to be changed, previously was 16
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}

Seems obvious now, but took me long enough to figure it out on my own.

How to change the minSdkVersion of a project?

Create a new AVD with the AVD Manager and set the Target to API Level 7. Try running your application with that AVD. Additionally, make sure that your min sdk in your Manifest file is at least set to 7.



Related Topics



Leave a reply



Submit