一、报错信息
An issue was found when checking AAR metadata:
1. Dependency 'androidx.activity:activity:1.8.0' requires libraries and applications that depend on it to compile against version 34 or later of the Android APIs.
:app is currently compiled against android-33.
Also, the maximum recommended compile SDK version for Android Gradle
plugin 7.4.2 is 33.
Recommended action: Update this project's version of the Android Gradle
plugin to one that supports 34, then update this project to use
compileSdkVerion of at least 34.
Note that updating a library or application's compileSdkVersion (which
allows newer APIs to be used) can be done separately from updating
targetSdkVersion (which opts the app in to new runtime behavior) and
minSdkVersion (which determines which devices the app can be installed
on).
二、错误分析(解决方案)
Dependency 'androidx.activity:activity:1.8.0' requires libraries and applications that depend on it to 「compile against version 34 or later of the Android APIs」。
从这段信息告诉我们,升级SDK这个是必须的,除非你不用。
2.1 升级SDK
app/build.gradle中将 compileSdk 和 targetSdk 升至 34 即可。
2.2 降低版本
Dependency androidx.activity:activity:1.8.0 必须34,那我不用就完事啦。
首先找到androidx.activity:activity:1.8.0在哪?
经过调研排查等最终确定是在「material」里面,操作如下:
dependencies {
//将1.10.0改为1.8.0即可
//implementation "com.google.android.material:material:1.10.0"
implementation "com.google.android.material:material:1.8.0"
}
具体采取哪种方案具体问题具体分析了,个人采用了「升级SDK」。
毕竟项目不大牵扯不是很很大,而且新内容是肯定要兼容的,嘿嘿嘿。