[英]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.