简体   繁体   中英

flutter - android minSdkVersion keeps making an error

Thanks for reading my question.

I hope you have a good day!

So my question is when I run my flutter project with android emulator, the error message below is shown.

The plugin google_mobile_ads requires a higher Android SDK version.
Fix this issue by adding the following to the file /Users/ahnjunhyun/FlutterProjects/dubu_timer/android/app/build.gradle:
android {
  defaultConfig {
    minSdkVersion 19
  }
}
Note that your app won't be available to users running Android SDKs below 19.
Alternatively, try to find a version of this plugin that supports these lower versions of the Android SDK.

So I changed minSdkVersion to minSdkVersion 19 . Then I got an another error like below!

FAILURE: Build failed with an exception.

* Where:
Build file '/Users/ahnjunhyun/FlutterProjects/dubu_timer/android/app/build.gradle' line: 47

* What went wrong:
A problem occurred evaluating project ':app'.
> Cannot get property '19' on null object

Is there someone who had same problem or knows how to fix?

I need your help

You must to update minSdkVersion 19 to 21 in order to use google_mobile_ads.

    defaultConfig {
      applicationId "io.flutter.plugins.googlemobileadsexample"
      minSdkVersion 21
      targetSdkVersion 31
      versionCode flutterVersionCode.toInteger()
      versionName flutterVersionName
      testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

Reference: https://github.com/googleads/googleads-mobile-flutter/blob/master/packages/google_mobile_ads/example/android/app/build.gradle

Maybe you have typed '19' as a String not an integer so please have a look.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM