The application could not be installed: INSTALL_PARSE_FAILED_MANIFEST_MALFORMED android 12

Viewed 15134

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)
   
1 Answers

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.

Related