【问题标题】:The application could not be installed: INSTALL_PARSE_FAILED_MANIFEST_MALFORMED android 12 [duplicate]无法安装应用程序:INSTALL_PARSE_FAILED_MANIFEST_MALFORMED android 12 [重复]
【发布时间】:2021-11-19 12:33:28
【问题描述】:

尝试在 android 12 设备中安装应用时出现以下错误。

Installation did not succeed.
The application could not be installed: INSTALL_PARSE_FAILED_MANIFEST_MALFORMED

错误

Installation failed due to: 'INSTALL_PARSE_FAILED_MANIFEST_MALFORMED: Failed parse during installPackageLI: /data/app/vmdl1707272647.tmp/base.apk (at Binary XML file line #98): aero.sita.airsideapp.activities.MainActivity: Targeting S+ (version 31 and above) requires that an explicit value for android:exported be defined when intent filters are present'

具有以下目标并编译 sdk 版本

 compileSdkVersion: 31,
 buildToolsVersion: "28.0.2",
 minSdkVersion    : 16,
 targetSdkVersion : 31,

版本降低到 30 可以正常工作,但是我不能使用android:windowSplashScreenBackground android 12 设备的启动屏幕背景更改参数

编辑:将android:exported="true" 添加到所有具有<intent-filters><activity><service><receiver> 组件,会在启动时使应用程序崩溃

崩溃日志

   java.lang.IllegalArgumentException: aero.sita.airsideapp.oneapp: Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent.
Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE if some functionality depends on the PendingIntent being mutable, e.g. if it needs to be used with inline replies or bubbles.
    at android.app.PendingIntent.checkFlags(PendingIntent.java:375)
    at android.app.PendingIntent.getBroadcastAsUser(PendingIntent.java:645)
    at android.app.PendingIntent.getBroadcast(PendingIntent.java:632)
    at androidx.work.impl.utils.ForceStopRunnable.getPendingIntent(ForceStopRunnable.java:273)
    at androidx.work.impl.utils.ForceStopRunnable.isForceStopped(ForceStopRunnable.java:151)
    at androidx.work.impl.utils.ForceStopRunnable.forceStopRunnable(ForceStopRunnable.java:171)
    at androidx.work.impl.utils.ForceStopRunnable.run(ForceStopRunnable.java:102)
    at androidx.work.impl.utils.SerialExecutor$Task.run(SerialExecutor.java:91)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
    at java.lang.Thread.run(Thread.java:920)
   

【问题讨论】:

  • Strongly consider using FLAG_IMMUTABLE 嗯...你已经了吗?
  • 不,我没有,我不知道在哪里使用这个标志
  • 啊哈.. 但是 logcat 会指示代码...或不?可能在您创建没有该标志的 PendingIntent 的服务中。只需在清单文件中注释掉服务即可查看是哪一个。或提供者..
  • 这可能来自您正在使用的库。并非所有内容都已为 Android 12 做好准备,您可能还拥有旧版本。无论如何,您可以通过 compileSdk 31 和 targetSdk 30 获得 Android 12 启动屏幕代码并避免这些问题。
  • @blackapps ,是的,我的应用程序中有服务从应用程序启动开始,但没有 logcat 没有提及任何代码或指向代码。它指向待处理的意图类,我将尝试将此标志添加到我的服务中

标签: android android-12


【解决方案1】:

INSTALL_PARSE_FAILED_MANIFEST_MALFORMED

您的清单条目中需要一个显式的 android:exported 值,作为应用程序的入口点。

将版本降低到 30 可以正常工作,但是我无法使用 android:windowSplashScreenBackground 启动屏幕背景更改参数为 android 12 设备

您可以使用带有 compileSdk 31 的 Android 12 启动画面 API,并通过使用 targetSdk 30 来避免 PendingIntent 问题。

java.lang.IllegalArgumentException:aero.sita.airsideapp.oneapp:定位 S+(版本 31 及更高版本)要求在创建 PendingIntent 时指定 FLAG_IMMUTABLE 或 FLAG_MUTABLE 之一。 强烈考虑使用 FLAG_IMMUTABLE,仅当某些功能依赖于 PendingIntent 是可变的时才使用 FLAG_MUTABLE,例如如果它需要与内联回复或气泡一起使用。

根据您的堆栈跟踪,这是来自 androidx-work 库。如果您的目标是 SDK 级别 31,则至少需要版本 2.7.0。版本 2.7.0 仍处于测试阶段。如果您更喜欢依赖项的稳定版本,请使用版本 2.6.0 和 targetSdk 30。

【讨论】:

  • 启动画面不显示 complieSdk 31 和 targetSdk 30 ,但显示 complieSdk 30 和 targetSdk 30 ,只是为了让你知道我没有编写任何代码来显示 splash ,它默认呈现安卓操作系统。
  • 更新到工作管理器 2.7.0 beta,并不能解决崩溃问题,我相信我还需要在 Pending Intent 中设置标志(FLAG_IMMUTABLE 或 FLAG_MUTABLE)
  • 通过主题属性的 Android 12 闪屏适用于我在 API 31 设备上运行时使用 targetSdk 30、compileSdk 31。对于崩溃问题,请继续检查堆栈跟踪以了解有问题的 PendingIntent 的位置。
  • 我刚刚观察到一件事,如果我使用应用程序图标从主屏幕启动应用程序,则启动画面显示,不管编译 sdk 版本是什么,29、30 和 31,但是当我启动它时使用 android studio 它不会在 android compile sdk 31 上显示,适用于 29 和 30。我相信这一定是 android studio 错误。对于崩溃,我将努力更新待处理的意图,感谢您的帮助
猜你喜欢
  • 2021-12-22
  • 2021-12-23
  • 2016-07-23
  • 2022-01-07
  • 1970-01-01
  • 2022-08-15
  • 1970-01-01
  • 2021-12-05
  • 1970-01-01
相关资源
最近更新 更多