skip to Main Content

I’m currently using Android studio attempting to run an old Flutter project I made about a year and a half ago. When I attempt to run it I get the error:

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.

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.

I am aware of similar questions having been asked and answered, but there is a key difference. The answer to these questions is to force gradle to use an older version of the package, yet as far as I have been able to figure out 1.0.0 is the lowest version of these dependencies.

I thought I could perhaps just remove the dependencies, but I’m not sure if I need them or how to even do that, but I cannot use an older version.

Currently my minSdkVersion is 21 and my targetSdkVersion as well as compileSdkVersion is 30. I tried just raising these numbers to 31 and 32, but that brought other issues up that I was not able to solve.

What are my options here? Can I remove the packages somehow? Should I upgrade to SDK 31 somehow?

UPDATE:

def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
    localPropertiesFile.withReader('UTF-8') { reader ->
        localProperties.load(reader)
    }
}

def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
    throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
    flutterVersionCode = '1'
}

def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
    flutterVersionName = '1.0'
}

apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
    compileSdkVersion 30

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

    defaultConfig {
        applicationId "com.example.r_app"
        minSdkVersion 21
        targetSdkVersion 30
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
    }

    buildTypes {
        release {
            // TODO: Add your own signing config for the release build.
            // Signing with the debug keys for now, so `flutter run --release` works.
            signingConfig signingConfigs.debug
        }
    }
}

flutter {
    source '../..'
}

dependencies {
    implementation platform('com.google.firebase:firebase-bom:28.0.1')
    implementation 'com.google.firebase:firebase-analytics-ktx'
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}

My build.gradle file as per @romtsn ‘s request.

Additionally I tried changing my SDK to a bunch of different options ranging from 30-32 in the Android Studio SDK manager, but to no avail.

5

Answers


  1. you need to decrease dependency versions which will be compatible with compile sdk 30.

    Login or Signup to reply.
  2. This is an interesting library to work with the Android framework.

    So My answer is twofold.

    1. THis library is for the foldable phones that are being introduced right now. This library’s APIs are a little bit different than other APIs if you want to use them. Some companies that make foldable phones use these APIs to make foldable phone-specific apps. Due to this API usage, you need to increase the SDK version inside the build.Gradle inside the app folder(App Level) file. These APIs are only supported by the higher version of the android version.
      (These APIs are released in 2022).

      In the Android documentation, it says the minimum SDK is 14 but that’s not the case. In the Microsoft documentation, it says compiled SDK is 31.
      Microsoft documentation

    2. If you haven’t installed the SDK files inside the android studio, You can download them in the SDK. And upgrade the version of compiled SDK version.

    Seems like you have two choices. Either you can compile the 31 version.
    Or

    You can delete the functionality or plugin that uses that API to support the
    multiple SDKs.

    Login or Signup to reply.
  3. replace this code:

    android {
        compileSdkVersion 30
    
        sourceSets {
            main.java.srcDirs += 'src/main/kotlin'
        }
    
        defaultConfig {
            applicationId "com.example.r_app"
            minSdkVersion 21
            targetSdkVersion 30
            versionCode flutterVersionCode.toInteger()
            versionName flutterVersionName
        }
    ...........
    
    dependencies {
        implementation platform('com.google.firebase:firebase-bom:28.0.1')
        implementation 'com.google.firebase:firebase-analytics-ktx'
        implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    }
    
    

    by the following

    android {
        compileSdkVersion 31
    
        sourceSets {
            main.java.srcDirs += 'src/main/kotlin'
        }
    
        defaultConfig {
            applicationId "com.example.r_app"
            minSdkVersion 21
            targetSdkVersion 31
            multiDexEnabled true
            versionCode flutterVersionCode.toInteger()
            versionName flutterVersionName
        }
    
    .......and.......
    dependencies {
        implementation platform('com.google.firebase:firebase-bom:28.0.1')
        implementation 'com.google.firebase:firebase-analytics-ktx'
        implementation 'com.google.guava:guava:27.0.1-android'
    }
    
    

    and add the line classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" in project_file -> android -> build.gradle :

     dependencies {
            classpath 'com.android.tools.build:gradle:4.1.3'
              ......
            classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 
        }
    

    After that open for editing in Android Studio on the top right.. Allow it to build. then Run. If required – flutter clean – pub_get in pubspec.yaml. I think this should work.. Because I am not sure what other requirements or errors you are getting.

    Login or Signup to reply.
    1. Just go to android studio settings page whether mac or windows

    2. search for SDK

    3. select

    4. Android SDK
      settings >> appearance and behaviour >> system settings >> android SDK

    5. make sure to tick Android SDK 31 or as per requirement.

    6. apply settings

    do flutter clean
    do flutter run

    Cheers !

    Login or Signup to reply.
  4. I had the same issue after migrating the old project to Null-Safety. This issue is most often seen with libraries that we declare. I fixed this issue by adding these lines inside default config in app level’s Gradle file.

            configurations.all {
            resolutionStrategy { force 'androidx.core:core:1.7.0-alpha01' }
            resolutionStrategy { force 'androidx.window:window-java:1.0.0-alpha10' }
            resolutionStrategy { force 'androidx.window:window:1.0.0-alpha10' }
        }
    

    So either upgrade your app’s CompileSdk & Target SDK to 31

        compileSdkVersion 31
        targetSdkVersion 31
    

    or Add these lines inside your app’s default config to fix the conflict forcefully having app’s Target and Compile SDK version to 30.

        defaultConfig {
        configurations.all {
            resolutionStrategy { force 'androidx.core:core:1.7.0-alpha01' }
            resolutionStrategy { force 'androidx.window:window-java:1.0.0-alpha10' }
            resolutionStrategy { force 'androidx.window:window:1.0.0-alpha10' }
        }
        applicationId "com.example.r_app"
        minSdkVersion 21
        targetSdkVersion 30
        multiDexEnabled true
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
    }
    

    Here you can find version info of different Artifact’s. Hope this would help you.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search