Home > database >  Flutter build failed after `flutter upgrade` to 2.10
Flutter build failed after `flutter upgrade` to 2.10

Time:02-26

What is causing the following build exception in an existing Flutter project after upgrading flutter to 2.10?

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:checkDebugAarMetadata'.
> Multiple task action failures occurred:
   > A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction
      > The minCompileSdk (31) specified in a
        dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)
        is greater than this module's compileSdkVersion (android-30).
        Dependency: androidx.window:window-java:1.0.0-beta04.
        AAR metadata file: C:\Users\Blah\.gradle\caches\transforms-2\files-2.1\602ce26881e3b92788ae83c190d3c36f\jetified-window-java-1.0.0-beta04\META-INF\com\android\build\gradle\aar-metadata.properties.
   > A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction
      > The minCompileSdk (31) specified in a
        dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)
        is greater than this module's compileSdkVersion (android-30).
        Dependency: androidx.window:window:1.0.0-beta04.
        AAR metadata file: C:\Users\Blah\.gradle\caches\transforms-2\files-2.1\9520e6f13992d2f4d96b17b856330597\jetified-window-1.0.0-beta04\META-INF\com\android\build\gradle\aar-metadata.properties.

CodePudding user response:

Flutter 2.10 support for Foldable devices via AndroidX

Flutter 2.10 Android Studio install SDK 31

Platform & Project Settings

Next we need to add Android SDK API 31 to our Project Structure under both Platform Settings and Project Settings

  • Android Studio > File > Project Structure
  • Under Platform Settings click SDKs
  • In the middle column click icon button, select "Add Android SDK.."
  • You will be prompted to select an Android SDK directory
    • Select your Android Sdk root directory like C:\Android\Sdk
    • do not select the specific API version like C:\Android\Sdk\platforms\android-31. This will be rejected.

Add SDK to Platform Settings

  • A "Create New Android SDK" window will pop up.
  • By default Java SDK 11 & Build target: Android API 31 will be preselected. If not, select them.
  • Click OK.

Select Build Target

  • Android API 31 Platform is now available for your Project.
  • Now under Project Settings, click on Project

Platforms available

  • On the right under Project SDK:
  • Click the dropdown list
  • Select Android API 31 Platform
  • Click OK

Select API 31 Platform

  • We're done.

Android 12 SDK API 31 is now installed and ready to compile this project.

CodePudding user response:

You should Set both compileSdkVersion and targetSdkVersion to 31 in your build.gradle(app) file.

android {
    compileSdkVersion 31 // <-- This
    defaultConfig {
        applicationId "com.example.app"
        targetSdkVersion 31 // <-- and this too
        // ...
    }
}
  • Related