当前位置: 首页 > 知识库问答 >
问题:

java - 关于androidx.appcompat:appcompat-resources:1.6.1要求使用更高版本进行编译的问题,要怎么解决合适?

龚博涛
2024-08-12

我在我的工程中可能依赖了androidx.appcompat:appcompat-resources:1.6.1相关的库,导致异常,它建议我更换成android-33
8 issues were found when checking AAR metadata:

  1. Dependency 'androidx.appcompat:appcompat-resources:1.6.1' requires libraries and applications that
    depend on it to compile against version 33 or later of the
    Android APIs.

    :app is currently compiled against android-31.

    Recommended action: Update this project to use a newer compileSdk
    of at least 33, for example 33.

    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.appcompat:appcompat:1.6.1' requires libraries and applications that
    depend on it to compile against version 33 or later of the
    Android APIs.

    :app is currently compiled against android-31.

    Recommended action: Update this project to use a newer compileSdk
    of at least 33, for example 33.

    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.activity:activity:1.6.0' requires libraries and applications that
    depend on it to compile against version 33 or later of the
    Android APIs.

    :app is currently compiled against android-31.

    Recommended action: Update this project to use a newer compileSdk
    of at least 33, for example 33.

    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.emoji2:emoji2-views-helper:1.2.0' requires libraries and applications that
    depend on it to compile against version 32 or later of the
    Android APIs.

    :app is currently compiled against android-31.

    Recommended action: Update this project to use a newer compileSdk
    of at least 32, for example 33.

    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.emoji2:emoji2:1.2.0' requires libraries and applications that
    depend on it to compile against version 32 or later of the
    Android APIs.

    :app is currently compiled against android-31.

    Recommended action: Update this project to use a newer compileSdk
    of at least 32, for example 33.

    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.core:core-ktx:1.9.0' requires libraries and applications that
    depend on it to compile against version 33 or later of the
    Android APIs.

    :app is currently compiled against android-31.

    Recommended action: Update this project to use a newer compileSdk
    of at least 33, for example 33.

    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).

  7. Dependency 'androidx.core:core:1.9.0' requires libraries and applications that
    depend on it to compile against version 33 or later of the
    Android APIs.

    :app is currently compiled against android-31.

    Recommended action: Update this project to use a newer compileSdk
    of at least 33, for example 33.

    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).

  8. Dependency 'androidx.annotation:annotation-experimental:1.3.0' requires libraries and applications that
    depend on it to compile against version 33 or later of the
    Android APIs.

    :app is currently compiled against android-31.

    Recommended action: Update this project to use a newer compileSdk
    of at least 33, for example 33.

    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).

我尝试将android-31更换成android-34,可以编译通过,但我的项目是android-31的,我需要在android-31去编译,我是否能通过将androidx.appcompat:appcompat-resources:1.6.1的版本降低到能够兼容android-31的版本,要怎么做,或者有更合适的方法推荐嘛

当我将保持 minSdkVersion 和 targetSdkVersion 为31,将 compileSdkVersion 更新为 33 或更高。可以编译通过并在我的平台安装,但是我尝试将jni的so放入我的工程,发现出现了这个异常
Cause: out extracted from path E: lib**_jni.so is not an ABI
我的so的信息为
file /system/lib64/lib**_jni.so
/system/lib64/lib**_jni.so: ELF shared object, 64-bit LSB arm64, for Android 31, BuildID=74ea3efed6754c43fce9f6b07e937eea, stripped
这要怎么做合适呢

共有1个答案

闻人嘉颖
2024-08-12

为了解决你遇到的问题,同时保持你的项目在 android-31 上编译,你有几个选项可以考虑:

1. 降级依赖库版本

如果可能的话,你可以尝试查找与 android-31 兼容的较低版本的库。但是,这可能需要你手动查找每个库的文档或发布说明来确定哪个版本是兼容的。此外,这可能会引入其他兼容性问题,因为较旧的库版本可能不包含你需要的某些功能或修复。

2. 使用条件编译

如果项目中只有部分模块或功能需要这些新版本的库,并且这些模块或功能不是必需的,你可以考虑使用条件编译来排除这些库。但这通常不是一个可行的解决方案,因为大多数库都是全局依赖的。

3. 更新 compileSdkVersion

尽管你提到项目需要在 android-31 上编译,但更新 compileSdkVersion 到更高版本(如 android-33android-34)通常不会影响应用的运行时兼容性。compileSdkVersion 主要影响编译时API的可用性,而运行时兼容性主要由 minSdkVersiontargetSdkVersion 决定。

  • 更新 compileSdkVersion: 在你的 build.gradle 文件中,将 compileSdkVersion 更新为 33 或更高。
  • 保持 minSdkVersiontargetSdkVersion 不变: 确保这些值保持为你需要的值(例如 android-31),以维持运行时兼容性。

4. 使用 Jetifier

如果你使用的是旧版本的 Android Gradle 插件,并且某些库需要更新到仅支持更高 API 级别的版本,你可以考虑使用 Jetifier。Jetifier 是一个转换工具,可以将库中的旧版支持库 API 调用转换为 AndroidX 等效项。但是,对于 compileSdkVersion 的要求,Jetifier 可能无法直接解决。

推荐的做法

由于大多数现代 Android 开发都倾向于使用较新的 API 和库版本,更新 compileSdkVersionandroid-33 或更高 是最推荐的解决方案。这样做可以确保你能够使用最新的 API 和库功能,同时仍然通过调整 minSdkVersiontargetSdkVersion 来维护运行时兼容性。

如果你确实需要在 android-31 上编译,但遇到了无法解决的依赖问题,那么可能需要重新评估你的项目需求或寻找替代的库版本。

 类似资料:
  • 问题内容: 我使用Android Studio,最近收到错误消息: 错误:任务’:app:compileDebugJavaWithJavac’的执行失败。compileSdkVersion’android-24’需要JDK 1.8或更高版本进行编译。 但是我已经安装了JDK 1.8: :\ Users ..> java -version Java版本“ 1.8.0_91” Java(TM)SE运行

  • 我今天做了一个新项目,想用Maven编译(我正在IntelliJ上运行它)。确保将JDK级别更改为1.8(这是我当前使用的),尝试编译,但我得到了很多异常要求我使用“-source 8”参数,因为默认参数是1.5,而且我使用的是较新的JDK版本的特性。 我已经很久没有使用IntelliJ了,有谁能告诉我如何改变这些Maven编译参数或者如何解决这个问题吗?

  • vue代码如下 在vue3版本使用vue2版本的script,通过点击字样可以弹出不同的内容 使用setup却无法达到这个功能,只有在console中显示

  • 问题内容: “ java.lang.Error:未解决的编译问题”的可能原因是什么? 附加信息: 从现有JAR顶部的版本复制一组更新的JAR文件并重新启动应用程序后,我已经看到了这一点。JAR是使用Maven构建过程构建的。 如果接口更改,我希望看到LinkageErrors或ClassNotFound错误。上面的错误提示存在一些较低级别的问题。 彻底的重建和重新部署解决了该问题。此错误是否表明J

  • 我使用Android Studio,最近得到了错误: 错误:任务“:app:CompileDebugJavaWithJavac”执行失败。compileSdkVersion“Android-24”需要JDK1.8或更高版本才能编译。 但我已经安装了JDK1.8: :\users..>java-version java version“1.8.0_91”java(TM)SE运行时 环境(build

  • 问题内容: 如何配置Maven编译器以将Java 5用于测试代码并将Java 1.4用于主代码? 问题答案: 如果要设置对相关Java版本的遵从性,则可以为每次执行配置编译器插件。假设Maven使用的JDK至少与您指定的最高版本相同。通过使用属性,可以在命令行或子项中覆盖该配置(如果需要): 如果您打算使用其他 编译器 ,则涉及的更多。因为您需要指定JDK的路径以及所使用的编译器版本。同样,这些可

  • 一直在尝试解决这个问题,但没能解决。这是udacity课程,我试图使用挂起的意图创建通知,但挂起的意图是可变的,我尝试了这种方式。 视图模型 片段 当我正在研究由gradle依赖项解决的其他类似问题时,我已经添加了 但是显示这个错误 Udacity启动器代码

  • 我使用android Studio制作了一个静态编程语言MultiPlatform Mobile项目,导入SQLDelight后遇到以下错误: 我回答了这个问题,但他们提到的一切我都做对了。在一个文件一个文件地查看之后,我没有找到我在哪里声明了那个版本,于是我决定将我的项目与其中一个示例项目进行比较。 再次查看这些文件后,我发现我在我的应用程序等级中使用了SQLDelightVersion1.5.