APK parsing issues building to Android 12

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.

Hi, I had the same issue and it’s related to the missing android:exported=“true” attribute in manifest for Unity activity. If you are using any SDK/Package check the manifests of that SDKs for the missing attribute. According to the bug report the Unity activity issue should be fixed in every updated Unity version now: Unity Issue Tracker - INSTALL_PARSE_FAILED_MANIFEST_MALFORMED errors are thrown when trying to run an Android application with target API level 31

The fix in other SDKs should look like this: Mobile Notification Package page-12#post-7694785

2 Likes

Cheers thankyou! I will try this out today and see if we can get any further with it

So I tried this fix, went through all manifest files where android:exported=“true” attribute needed to be added with no luck sadly

Try to export the project, open it in Android Studio and inspect the AndroidManifest there. Some packages/SDK add entries to the manifest via script, so you won’t find it in Assets in Unity.

Cheers for that, however it fails to build with this error on android studio il2cpp.exe fatal error: ‘stb_image.h’ file not found

You don’t need to build the project in Android Studio, you just need to open the project there and check the AndroidManifest or you can check the manifest directly without Android Studio. You can find it inside the exported project folder at path: “.\unityLibrary\src\main\AndroidManifest.xml”.

how did you solve it?

The exact same thing happens to me with android 12. I use unity 2018.4.f1 and when compiling my project there is no problem but when installing it on a device it cannot analyze it. i tried compiling with api 31 and 32 and even 33 but it just won’t install.

Me too, i am facing “There is a problem parsing the package”.
i’m exporting APK using Unity 2018. Target Api in Player Settings is 32. The exported APK is working good on Galaxy J7 Phone ( android 9 ) but firing this error on my S10+ ( android 12 )
i tried changing android:exported ==> True, but i still have same error.
Please help me

Try installing from terminal via adb and share the complete error log.
If you can share an empty apk(with all scenes removed), that will be fine too or a merged manifest file.

To solve this problem, open the apk in Android Studio and look into manifest. All activities, receivers, services have to have exported attributes. The ones that don’t have it are causing you this problem.

not work

I have a small Unity 2D app that I successfully installed on an Android 11 phone. When I tried to install the APK
on various Android 13 phones I received the following error: ‘app not installed as package appears to be invalid’
I the took the advice received here and edited the AndroidManifest file but no joy! I changed the
install location to automatic. My minimum API level is 24 and Target API is 33. Anyone that had the same problem?
Any advise/solution would be greatly appreciated.

Share an empty apk(without any scenes) or merged manifest file to look into.
Most likely the error sounds like missing exported flag which is a requirement from Android 12 devices.