首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >此编译器不支持31的API级别。请使用30或更早的API级别。

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

Stack Overflow用户
提问于 2021-12-11 02:30:52
回答 2查看 15.1K关注 0票数 14

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

代码语言:javascript
复制
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或真正的设备来调试这个应用程序。我得到了这个错误。

代码语言:javascript
复制
> 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

我想我需要更新编译器,我怎么做呢?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2021-12-13 23:53:09

尝试将其添加到build.gradle文件中:

代码语言:javascript
复制
android {
  ...
  compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
  }
  kotlinOptions {
    jvmTarget = '1.8'
  }
}
票数 12
EN

Stack Overflow用户

发布于 2022-03-09 01:32:23

您使用的gradle版本似乎无法使用D8。但是改变gradle版本可能是个大问题。尤其是为了维护老项目。而且D8似乎是用来减少APK文件大小的。这只是警告而不是错误。所以,合理的行动可能是..。忽略这条信息。:)

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/70312198

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档