賞金將在 4 天后到期。此問題的答案有資格獲得 50聲望賞金。 RGA希望引起對這個問題的更多關注。
我目前正在使用 Android Studio 嘗試運行我大約一年半前制作的舊 Flutter 專案。當我嘗試運行它時,出現錯誤:
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.
我知道有人提出并回答了類似的問題,但有一個關鍵的區別。這些問題的答案是強制 gradle 使用舊版本的包,但據我所知 1.0.0 是這些依賴項的最低版本。
我想我也許可以洗掉依賴項,但我不確定我是否需要它們或者如何做到這一點,但我不能使用舊版本。
目前我的 minSdkVersion 是 21,我的 targetSdkVersion 和 compileSdkVersion 是 30。我嘗試將這些數字提高到 31 和 32,但這帶來了其他我無法解決的問題。
我在這里有什么選擇?我可以以某種方式洗掉包裹嗎?我應該以某種方式升級到 SDK 31 嗎?
更新:
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"
}
根據@romtsn 的要求,我的 build.gradle 檔案。
此外,我嘗試在 Android Studio SDK 管理器中將我的 SDK 更改為一系列不同的選項,范圍從 30 到 32,但無濟于事。
uj5u.com熱心網友回復:
替換此代碼:
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"
}
通過以下
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'
}
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"并在 project_file -> android -> build.gradle 中添加該行:
dependencies {
classpath 'com.android.tools.build:gradle:4.1.3'
......
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
之后open for editing in Android Studio在右上角.. 允許它構建。然后運行。如果需要 - 顫振干凈 - pubspec.yaml 中的 pub_get。我認為這應該可行。因為我不確定您遇到了哪些其他要求或錯誤。
uj5u.com熱心網友回復:
這是一個與 Android 框架一起作業的有趣庫。
所以我的回答是雙重的。
該庫適用于目前正在推出的可折疊手機。如果你想使用這個庫的 API,它們與其他 API 有點不同。一些制造可折疊手機的公司使用這些 API 來制作可折疊手機專用的應用程式。由于此 API 的使用,您需要在 app 檔案夾(App Level)檔案中的 build.Gradle 中增加 SDK 版本。這些 API 僅受更高版本的 android 版本支持。(這些 API 于 2022 年發布)。
在 Android 檔案中,它說最低 SDK 是 14,但事實并非如此。在 Microsoft 檔案中,它說編譯后的 SDK 為 31。 Microsoft 檔案
如果您還沒有在 android studio 中安裝 SDK 檔案,您可以在 SDK 中下載它們。并升級編譯后的SDK版本。
好像你有兩個選擇。要么你可以編譯31版本。要么
您可以洗掉使用該 API 來支持多個 SDK 的功能或插件。
uj5u.com熱心網友回復:
您需要減少與 compile sdk 30 兼容的依賴版本。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/432352.html
