赞
踩
新建一个程序,Build-Make Project后构建失败,点击报错详情如下:
6 issues were found when checking AAR metadata:
1. Dependency 'androidx.navigation:navigation-common:2.7.6' 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 8.1.0 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
compileSdk of at least 34.Note that updating a library or application's compileSdk (which
allows newer APIs to be used) can be done separately from updating
targetSdk (which opts the app in to new runtime behavior) and
minSdk (which determines which devices the app can be installed
on).2. Dependency 'androidx.navigation:navigation-runtime:2.7.6' 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 8.1.0 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
compileSdk of at least 34.Note that updating a library or application's compileSdk (which
allows newer APIs to be used) can be done separately from updating
targetSdk (which opts the app in to new runtime behavior) and
minSdk (which determines which devices the app can be installed
on).3. Dependency 'androidx.navigation:navigation-fragment:2.7.6' 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 8.1.0 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
compileSdk of at least 34.Note that updating a library or application's compileSdk (which
allows newer APIs to be used) can be done separately from updating
targetSdk (which opts the app in to new runtime behavior) and
minSdk (which determines which devices the app can be installed
on).4. Dependency 'androidx.navigation:navigation-ui:2.7.6' 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 8.1.0 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
compileSdk of at least 34.Note that updating a library or application's compileSdk (which
allows newer APIs to be used) can be done separately from updating
targetSdk (which opts the app in to new runtime behavior) and
minSdk (which determines which devices the app can be installed
on).5. Dependency 'androidx.activity:activity-ktx: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 8.1.0 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
compileSdk of at least 34.Note that updating a library or application's compileSdk (which
allows newer APIs to be used) can be done separately from updating
targetSdk (which opts the app in to new runtime behavior) and
minSdk (which determines which devices the app can be installed
on).6. 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 8.1.0 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
compileSdk of at least 34.Note that updating a library or application's compileSdk (which
allows newer APIs to be used) can be done separately from updating
targetSdk (which opts the app in to new runtime behavior) and
minSdk (which determines which devices the app can be installed
on).
根据报错信息的提示,6个问题报错均来自SDK版本不够的问题,同时结合其推荐的解决方案:【Recommended action: Update this project's version of the Android Gradle plugin to one that supports 34, then update this project to use compileSdk of at least 34.】需要将SDK版本升级到34。通过查询站内其他文章,只需找到app/build.gradle,将其中的 compileSdk 和 targetSdk 改写为 34 即可。
但由此又遇到另一个尴尬的问题:找不到app/build.gradle文件:
经过查找,这个似乎也是一个比较常见的问题(虽然不知道为什么会出现这种问题),但按照许多文章的方法尝试过都无法打开。然后在这篇文章中找到一段话:
的确,打开项目级别的build.gradles.kts文件后,里面只有关于gradle版本的配置:
于是按图索骥,在项目根目录/模块目录下找到了模块级别的build.gradles文件:
将其用AS打开,成功找到了改写SDK版本的build.gradles文件,接下来只需将compileSdk 和 targetSdk 改写为 34 即可:
重新Make Project,错误解决。
但仍有警告,将其详细信息摘录如下:
We recommend using a newer Android Gradle plugin to use compileSdk = 34
This Android Gradle plugin (8.1.0) was tested up to compileSdk = 33 (and compileSdkPreview = "UpsideDownCakePrivacySandbox").
You are strongly encouraged to update your project to use a newer Android Gradle plugin that has been tested with compileSdk = 34.
If you are already using the latest version of the Android Gradle plugin,
you may need to wait until a newer version with support for compileSdk = 34 is available.To suppress this warning, add/update
android.suppressUnsupportedCompileSdk=34
to this project's gradle.properties.
按照警告中最后提及的解决方案,找到项目级别的gradle.properties文件,并将android.suppressUnsupportedCompileSdk=34代码写入,重新运行,警告解除。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。