gpt4 book ai didi

android - 此编译器不支持 API 级别 31。请使用 30 或更早的 API 级别

转载 作者:行者123 更新时间:2023-12-04 23:39:37 36 4
gpt4 key购买 nike

我将现有的 android 项目升级到 API 级别 31。我使用 Java 作为语言。我改变了 build.gradle

compileSdkVersion 31
defaultConfig {
applicationId 'com.app.app'
minSdkVersion 16
targetSdkVersion 31
versionCode 91
versionName '4.0.1'
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
但我无法使用 AVD 或真实设备调试应用程序。我收到这个错误。
> Task :app:mergeProjectDexDebug
AGPBI: {"kind":"warning","text":"An API level of 31 is not supported by this compiler. Please use an API level of 30 or earlier","sources":[{}],"tool":"D8"}
AGPBI: {"kind":"warning","text":"An API level of 31 is not supported by this compiler. Please use an API level of 30 or earlier","sources":[{}],"tool":"D8"}
AGPBI: {"kind":"warning","text":"An API level of 31 is not supported by this compiler. Please use an API level of 30 or earlier","sources":[{}],"tool":"D8"}
AGPBI: {"kind":"warning","text":"An API level of 31 is not supported by this compiler. Please use an API level of 30 or earlier","sources":[{}],"tool":"D8"}
AGPBI: {"kind":"warning","text":"An API level of 31 is not supported by this compiler. Please use an API level of 30 or earlier","sources":[{}],"tool":"D8"}
AGPBI: {"kind":"warning","text":"An API level of 31 is not supported by this compiler. Please use an API level of 30 or earlier","sources":[{}],"tool":"D8"}
AGPBI: {"kind":"warning","text":"An API level of 31 is not supported by this compiler. Please use an API level of 30 or earlier","sources":[{}],"tool":"D8"}
AGPBI: {"kind":"warning","text":"An API level of 31 is not supported by this compiler. Please use an API level of 30 or earlier","sources":[{}],"tool":"D8"}
AGPBI: {"kind":"warning","text":"An API level of 31 is not supported by this compiler. Please use an API level of 30 or earlier","sources":[{}],"tool":"D8"}
An API level of 31 is not supported by this compiler. Please use an API level of 30 or earlier
我想我需要更新编译器,我该怎么做?

最佳答案

尝试将此添加到您的 build.gradle 文件:

android {
...
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
}

关于android - 此编译器不支持 API 级别 31。请使用 30 或更早的 API 级别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70312198/

36 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com