minCompileSDK specified in dependency AAR metadata (androidx.window:window:1.0.0-beta04)
Solution 1
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.
Solution 2
This is an interesting library to work with the Android framework.
So My answer is twofold.
-
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
-
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.
Solution 3
-
Just go to android studio settings page whether mac or windows
-
search for SDK
-
select
-
Android SDK settings >> appearance and behaviour >> system settings >> android SDK
-
make sure to tick Android SDK 31 or as per requirement.
-
apply settings
do flutter clean do flutter run
Cheers !
Admin
Updated on January 03, 2023Comments
-
Admin 10 months
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.
-
Hooman over 1 yearjust increase your compileSdkVersion to 31 and not targetSdkVersion.
-
GentleAutumnRain over 1 year@Hooman I have tried that, same results.
-
RGA over 1 yearI'm having the exact same issue, interestingly cropped up a few days after yours. I'm adding a bounty to this to help get us an answer
-
RGA over 1 yearInterestingly, if I create a new flutter project, it doesn't have any issues compiling and running. My short term solution will be to just create a new project and copy over assets and .dart files. Still would like to know if there's a better solution
-
romtsn over 1 yearSo you have 2 options, either you update your compileSdkVersion to 31 and resolve what's required for that, or remove
androidx.window
. If it comes transitively though, I'd go for the first option, cause it might break otherwise -
GentleAutumnRain over 1 year@romtsn I wasn't able to figure out how to remove a dependency like that. Do you perhaps have a link to a guide or something? I can't find it online.
-
GentleAutumnRain over 1 year@RGA Ah I'll try creating a new one as well. That'd be good enough for me. I just need it to work.
-
romtsn over 1 year@GentleAutumnRain you'd need to share your build.gradle file, so I can understand where this dependency is coming from
-
GentleAutumnRain over 1 year@romtsn added it to the question. I couldn't figure out myself why it was being added.
-
-
RGA over 1 yearIn my case, downloading 31, creating an entirely new flutter project, and copying in my relevant files did allow it to work (although now I have some other warnings popping up from gradle - problem for a future day), but this is not a satisfying workaround. Could you elaborate on how we might follow either of your two paths directly within the original flutter project?
-
raj kavadia over 1 year@RGA This is the compiled SDK, not the minimum SDK. It will still work on the previous version.