The error message “an API level of 31 is not supported by this compiler. Please use an API level of 30 or earlier” indicates that the current compiler you are using does not support API level 31. You are required to use a lower API level, specifically level 30 or earlier, in order to resolve this issue.
An API level refers to the version of the API (Application Programming Interface) provided by the Android platform. Each API level introduces new features, updates, and improvements to the platform. The compiler, being a tool that translates your source code into machine-readable instructions, needs to support the specific API level you are targeting.
To rectify this issue, you have two options:
- Change the target API level in your project settings to 30 or an earlier version. This ensures that the compiler uses the corresponding API level and is able to compile your code successfully. Here’s an example of how you can specify the target API level in the “build.gradle” file of an Android project:
android { compileSdkVersion 30 // Other build configurations }
- Update your compiler to a version that supports API level 31. This might involve upgrading your development environment or using a different compiler altogether, depending on the tools you are currently utilizing.
Same cateogry post
- Store.getstate is not a function
- No context provided: useleafletcontext() can only be used in a descendant
- Cannot find module ‘@react-native/metro-config’
- Error: could not find a version that satisfies the requirement open3d (from
versions: none) error: no matching distribution found for open3d
- Unable to resolve class com.android.build.outputfile