Problem parsing package with API level 31

I have spent a good chunk of time trying to look into every avenue to get this to work and really struggling now. So I am currently trying to build to API Level 31 on Unity 2021.2.1f1, It successfully builds and generated the APK file as intended however, When clicking to install on ANY android 12 device it starts the install process trying to parse the file however it comes back to say it failed to parse. To note running the same APK on any other version of android works perfectly fine this seems to just be android 12 issue. I am defiantly building for android 12 (API Level 31). I have even tried to export the project from unity to open and build the APK through android studio, Android studio will build the APK and when running on android 12 devices will get past the parsing issue and install correctly So i was thinking there must be something going wrong on unity’s side of thing. I have tried to use the latest 2022 version of unity also with the issue being produced.

Also to note Android API Level 31 is fully installed correctly and it is selected manually in unity settings,I have spent a good chunk of time trying to look into every avenue to get this to work and really struggling now. So I am currently trying to build to API Level 31 on Unity 2021.2.1f1, It successfully builds and generated the APK file as intended however, When clicking to install on ANY android 12 device it starts the install process trying to parse the file however it comes back to say it failed to parse. To note running the same APK on any other version of android works perfectly fine this seems to just be android 12 issue. I am defiantly building for android 12 (API Level 31). I have even tried to export the project from unity to open and build the APK through android studio, Android studio will build the APK and when running on android 12 devices will get past the parsing issue and install correctly So i was thinking there must be something going wrong on unity’s side of thing. I have tried to use the latest 2022 version of unity also with the issue being produced.

Also to Note i can confirm API Level 31 is selected and is installed

Hi, this is my first comment ever on Unity forums, and I’m here because I found a solution that works for me:

  • In the Player Settings before building, at the Other Settings/Configuration tab you want to set the target API to Android 10.0. (Yes, even if you have a newer version.)

I don’t know why, but it worked for me after pointlessly searching on every forum. In my case, a game was previously installed on the phone, then ever since the latest software update it got automatically deleted and the APK said “There was an error parsing the package”. This solution helped without a problem.

Hope I helped at least one clueless person googling this question.

hi , this is work for me
simple solution is to create custom manifest.xml
In Project Settings > Player > Android > Publishing Settings > Build, select Custom Main Manifest.
Apply the following changes to Assets/Plugins/Android/AndroidManifest.xml:

Add the android:exported attribute to the tag:

 <activity android:name="com.unity3d.player.UnityPlayerActivity"
           android:theme="@style/UnityThemeSelector"
           android:exported="true">
     <intent-filter>
         <action android:name="android.intent.action.MAIN" />
         <category android:name="android.intent.category.LAUNCHER" />
     </intent-filter>
     <meta-data android:name="unityplayer.UnityActivity" android:value="true" />
 </activity>

There might be some issue related to AndroidManifest.xml.
You have to set android:exported=“true” on your receivers.
I found the solution here: https://forum.unity.com/threads/mobile-notification-package.620227/page-12#post-7694785

Also changing the target API to 30 works, but I don’t recommend it.