Search code examples
fluttersettingsupgrade

Upgrading the Android SDK version


Android Studio -> System Settings -> SDK Android -> SDK Platforms Android 13.0(Tiramisu) Installed. I'm trying to upgrade the Android SDK version to 33.

I am getting Warning error:

The plugin flutter_email_sender requires Android SDK version 33.

Inside app/build.gradle file I have: '''Dart android {

**compileSdkVersion flutter.compileSdkVersion **

        ndkVersion flutter.ndkVersion
        compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    kotlinOptions {
        jvmTarget = '1.8'
    }

    sourceSets {
        main.java.srcDirs += 'src/main/kotlin'
    }

    defaultConfig {
        
**minSdkVersion flutter.minSdkVersion**
**targetSdkVersion flutter.targetSdkVersion**

I change to:

compileSdkVersion 33

targetSdkVersion 33 ''' I save the file, compile the project and i get an error:

Build file 'C:\Users\Admin\AndroidStudioProjects\rozdzielnia\android\build.gradle' line: 26*** What went wrong: A problem occurred evaluating root project 'android'.

A problem occurred configuring project ':app'. Could not open proj generic class cache for build file 'C:...\android\app\build.gradle' (C:\Users\Admin.gradle\caches\7.4\scripts\54yso35ibf29r0rk62zlu1wmq). BUG! exception in phase 'semantic analysis' in source unit 'BuildScript' Unsupported class file major version 63**

I found the presented solution on the forum. However, I don't know what is causing the error and how to fix it.


Solution

  • Go to

    android/app/src/build.gradle

    inside android class change it to 33

    android {
    compileSdkVersion 33 // <== Here's your compiled version
    ...
    ..
    }
    

    and inside android class there is another class called defaultConfig

    defaultConfig {
        applicationId "your.app.bundle"
        minSdkVersion 21 // <== checkout y
        targetSdkVersion 33 // <== make sure this is 33
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
    }
    

    and inside your AndroidManifest.xml

    android/app/src/main/AndroidManifest.xml

    you must add these lines of code to support android 11

    <queries>
      <intent>
        <action android:name="android.intent.action.SENDTO" />
        <data android:scheme="mailto" />
       </intent>
     </queries>