简体   繁体   English

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

[英]An API level of 31 is not supported by this compiler. Please use an API level of 30 or earlier

I upgrade existing android project to API level 31. I use Java as the language.我将现有的 android 项目升级到 API 级别 31。我使用 Java 作为语言。 I changed the build.gradle我改了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
}

But I couldn't debug the app using an AVD or a real device.但我无法使用 AVD 或真实设备调试应用程序。 I am getting this error.我收到此错误。

> 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

I think I need to update the compiler, How can I do that?我想我需要更新编译器,我该怎么做?

It seems that D8 is not available for the gradle version you used.你用的gradle版本好像没有D8。 But change gradle version might be a big deal.但是更改 gradle 版本可能是一个大问题。 Especially for maintaining old project.特别是对于维护旧项目。 And it seems that D8 is used to reduce APK file size.而且似乎 D8 是用来减小 APK 文件大小的。 And it's just warning, not error.它只是警告,而不是错误。 So, the reasonable action might be... ignore the message.所以,合理的行动可能是……忽略这条消息。 :) :)

Try adding this to your build.gradle file:尝试将此添加到您的build.gradle文件中:

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 此编译器不支持 API 级别 31 - Android - API level of 31 is not supported by this compiler - Android 您的应用当前针对 API 级别 30,并且必须至少针对 API 级别 31 - Your app currently targets API level 30 and must target at least API level 31 Cordova - this.http.get() 请求不适用于 API 级别 31(它在 API 级别 30 中工作) - Cordova - this.http.get() request does not work with API level 31( It was working in API level 30) 无法将 Cordova 应用程序提交到 Play 商店 - (您的应用程序当前针对 API 级别 30,并且必须至少针对 API 级别 31) - Can't submit Cordova app to the Play Store - (Your app currently targets API level 30 and must target at least API level 31) 您的应用目前以 API 级别 30 为目标,并且必须至少以 API 级别 31 为目标,以确保它是基于最新的 API 构建的 - Your app currently targets API level 30 and must target at least API level 31 to ensure it is built on the latest APIs 在 API 级别 30 中不推荐使用 getSize() - getSize() deprecated in API level 30 GoogleServices API级别的更改早于Nougat(API级别24) - GoogleServices API level changing for earlier than Nougat (API level 24) Android:早期API级别的可绘制资源 - Android: drawable resource from earlier API level WebSetting allowFileAccessFromFileURLs 在 API 级别 30 中已弃用 - WebSetting allowFileAccessFromFileURLs is Deprecated in API Level 30 预期 Android API 级别 21+ 但为 30 - Expected Android API level 21+ but was 30
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM