Android Studio 在依赖项AAR元数据中指定了minCompileSDK(androidx.窗口:窗口:1.0.0-beta 04)

rggaifut  于 2022-11-16  发布在  Android
关注(0)|答案(5)|浏览(224)

我目前正在使用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"
}

我的build.gradle文件按照@romtsn的要求。
此外,我尝试在Android Studio SDK管理器中将我的SDK更改为一系列不同的选项,范围从30-32,但无济于事。

mxg2im7a

mxg2im7a1#

替换以下代码:

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'
}

然后在project_file -〉android -〉build.gradle中添加classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"行:

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之后..允许它构建。然后运行。如果需要- flutter clean -pubspec. yaml中的pub_get。我认为这应该可以工作..因为我不确定你得到的其他要求或错误。

xtfmy6hx

xtfmy6hx2#

这是一个与Android框架配合使用的有趣库。
所以我的答案是双重的。
1.这个库是为现在正在推出的可折叠手机准备的。如果你想使用它,这个库的API和其他API有点不同。一些生产可折叠手机的公司使用这些API来生产可折叠手机专用的应用程序。由于这种API的使用,您需要在app文件夹中的build.gradle中增加SDK版本(App Level)文件。这些API仅在更高版本的android版本中支持。(这些API将于2022年发布)。
在Android文档中,它说最低SDK是14,但事实并非如此。在微软文档中,它说编译的SDK是31。Microsoft documentation
1.如果你还没有安装的SDK文件内的android工作室,你可以下载他们在SDK.并升级版本编译SDK版本.
看起来你有两个选择。要么你可以编译31版本。要么
您可以删除使用该API支持多个SDK的功能或插件。

nhaq1z21

nhaq1z213#

1.只要去android studio设置页面无论是mac或windows
1.搜索SDK
1.精选
1.安卓软件开发工具包settings >> appearance and behaviour >> system settings >> android SDK
1.确保勾选Android SDK 31或根据要求。
1.应用设置
做Flutter清理做Flutter运行
干杯!干杯!

3vpjnl9f

3vpjnl9f4#

在将旧项目迁移到Null-Safety后,我遇到了同样的问题。这个问题在我们声明的库中最常见。我通过在应用级别的Gradle文件的默认配置中添加这些行来修复这个问题。

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' }
    }

因此,要么将应用的CompileSdk和Target SDK升级到31

compileSdkVersion 31
    targetSdkVersion 31

或将这些行添加到应用的默认配置中,以强制将应用的目标和编译SDK版本设置为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您可以找到不同工件的版本信息。希望这对您有所帮助。

bq3bfh9z

bq3bfh9z5#

您需要减少与编译sdk30兼容的依赖版本。

相关问题