Search code examples
flutterflutter-dependenciesflutter-packagesgoogle-mobile-ads

Missing compileSdkVersion for google mobile ads


defaultConfig {
    // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
    applicationId "com.example.ringit2"
    minSdkVersion 21
    targetSdkVersion 30
    versionCode flutterVersionCode.toInteger()
    versionName flutterVersionName
}

Here is what I found on my build.gradle and I can't find compileSdkVersion which I have to change to at least 28 in order for google mobile ads to operate.

After I added google_mobile_ads: ^1.1.0 on pubspec.yaml and imported the package to the main.dart, The app opens as I run the simulator but shuts down right away. Console shows me this message and it is stuck just like this forever.

Launching lib\main.dart on SM G950N in debug mode...
Running Gradle task 'assembleDebug'...
√  Built build\app\outputs\flutter-apk\app-debug.apk.
Installing build\app\outputs\flutter-apk\app.apk...

Please note that my ext.kotlin_version is '1.6.10' because people have recommended to upgrade it

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-all.zip

Also changed the distributionUrl...

enter image description here

Not sure why google mobile ads package is so hard to use even just to start but what should I change to use it?


Solution

  • I am also using kotlin version '1.6.10' and compilesdk version is inside android>app>build.gradle

    enter image description here