12

Getting the following error when trying to install the app in android 12 device.

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

Error

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'

Have following target and complie sdk verions

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

Reducing the version to 30 works fine, but then I can't use android:windowSplashScreenBackground splash screen background change parameters for android 12 device

Edit : Adding android:exported="true" to all <activity>,<service>, or <receiver> components that have <intent-filters> , crashes the application on launch

Crash Logs

   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)
   
Nitish
  • 3,075
  • 3
  • 13
  • 28
  • `Strongly consider using FLAG_IMMUTABLE` Well... did you already? – blackapps Sep 27 '21 at 10:55
  • No I haven't , I have no idea where to use this flag – Nitish Sep 27 '21 at 10:55
  • Aha.. but the logcat will indicate the code... or not? Probably in a service where you create a PendingIntent without that flag. Just comment out services in manifest file to see which one. Or the providers.. – blackapps Sep 27 '21 at 10:57
  • That might come from a library you're using. Not everything is yet ready for Android 12, and you might also have older versions. Anyway, you can have Android 12 splashscreen code and avoid these issues by having compileSdk 31 and targetSdk 30. – laalto Sep 27 '21 at 10:58
  • @blackapps , yes I have service in my app which start on app launch , but no logcat didn't mention any code or point to code. It points pending intent classes , I will try adding this flag to my services – Nitish Sep 27 '21 at 11:01
  • @laalto , I don't think it's a good idea to use different version for compileSdk and targetSdk , it's better if I don't migrate to android 12 yet , if that's the case , – Nitish Sep 27 '21 at 11:03
  • You'll get a warning from the tools about by not targeting the latest SDK but that's it. – laalto Sep 27 '21 at 11:08
  • @blackapps , I commented out all the services from the manifest , so ideally they shouldn't run , but I still got the crash. Also I have attached the full crash logs – Nitish Sep 27 '21 at 11:22
  • Not enough logcat. But... `PendingIntent.checkFlags(PendingIntent.java:375)` Look in your code where you create PendingIntent's.. – blackapps Sep 27 '21 at 11:24
  • @laalto , If I use targetSdk 30 , I no longer the see default splash screen of android 12 – Nitish Sep 27 '21 at 11:25
  • @blackapps , only this is printed in the logcat , I can't see any more error there , I will check all the PendingIntents in the code – Nitish Sep 27 '21 at 11:28

1 Answers1

24

INSTALL_PARSE_FAILED_MANIFEST_MALFORMED

You need an explicit android:exported value in your manifest entries that constitute as entry points to your application.

Reducing the version to 30 works fine, but then I can't use android:windowSplashScreenBackground splash screen background change parameters for android 12 device

You can use Android 12 splashscreen APIs with compileSdk 31 and avoid the PendingIntent problem by using targetSdk 30.

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.

Based on your stacktrace this is from the androidx-work library. You need at least version 2.7.0 if you're targeting SDK level 31. Version 2.7.0 is still in beta. If you prefer stable versions of your dependencies, go with version 2.6.0 and targetSdk 30.

laalto
  • 150,114
  • 66
  • 286
  • 303
  • Splash screen doesn't show with complieSdk 31 and targetSdk 30 , but shows with complieSdk 30 and targetSdk 30 , just to let you know I haven't written any code to show splash , it rendered by default by android OS. – Nitish Sep 27 '21 at 11:48
  • Updating to work manager 2.7.0 beta , doesn't resolve the crash , I believe I need to set flags(FLAG_IMMUTABLE or FLAG_MUTABLE ) in Pending Intent also – Nitish Sep 27 '21 at 11:49
  • Android 12 splashscreen via theme attributes works for me with targetSdk 30, compileSdk 31 when running on API 31 device. For the crash issues, keep on examining the stacktrace to learn the location of the offending PendingIntents. – laalto Sep 27 '21 at 11:52
  • I just observed one thing , splash shows if I launch the app from home screen using app icons, doesn't matter what's the compile sdk version is , 29, 30 and 31 , but when I launch it using android studio it doesn't show on android compile sdk 31, works on 29 and 30. I believe this must be android studio bug. For crash I will be working on updating the pending intent , Thanks for the help – Nitish Sep 27 '21 at 11:57
  • 1
    in my case minSdkVersion 19 targetSdkVersion 30 environment: sdk: ">=2.16.0 <3.0.0" Flutter 2.10.0 Working perfectly – Kalyan Biswas May 20 '22 at 09:02