Search code examples
androidfluttergradleandroid-manifest

Android minSdkVersion with Flutter(v2.8.1)


I have installed the firebase package. as we know minSdkVersion 19 is recommended. So, I wanted to do this process. however, I saw that this line is included in the android/app/build.gradle file

minSdkVersion flutter.minSdkVersion

The previous view would be as follows

minSdkVersion 16

Is it possible to change the version with a file? that is, whether the value for minSdkVersion is split into another file?

Thanks!


Solution

  • 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()