Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Bug "App not installed as package appears to be invalid" installing Android app built for API level 31

Discussion in 'Android' started by dtootill, Nov 17, 2022.

  1. dtootill

    dtootill

    Joined:
    Oct 9, 2020
    Posts:
    21
    I have a Unity project using 2020.3.41f1 with apps published on both the App Store and Play Store. The build for the published Play Store app targets API level 30. Unfortunately, Google now requires a minimum of API level 31 for published builds, so when the app needed an update, I attempted to build it with an API level 31 target, starting with an APK build for ease of verification. The build completed with no errors. However, when I attempt to install the output APK, the install fails with the error "App not installed as package appears to be invalid".

    I tried upgrading the project to 2021.3.13f1, including deleting and rebuilding the Library directory after the upgrade. The upgraded project also successfully builds an app targeting API level 31. Unfortunately, an Android install of the app fails with the same error.

    I notice that the Target API Level dropdown in Project Settings in both 2020.3.41f1 and 2021.3.13f1 lists an Android operating system for API levels 30 and below (entries of the form "Android 11.0 (API level 30)") but omits it for API levels 31 and above (entries of the form "API level 31"). Does this indicate something is missing?

    In any case, has anyone successfully built an Android app targeting API level 31 or above? If so, what do I need to do to create an installable build, or look at to diagnose this problem?
     
    Last edited: Nov 17, 2022
  2. Voxel-Busters

    Voxel-Busters

    Joined:
    Feb 25, 2015
    Posts:
    1,828
    Share the error you got while installing. If its something to do with exported flag, share an empty apk or merged manifest file to look into whats causing the problem.
     
  3. flintcheeze

    flintcheeze

    Joined:
    Sep 10, 2015
    Posts:
    80
    I have been able to build with Api level 33 which I installed via Android studio and then restarted Unity, clicked on use the highest installed 1st and then build note: it will still build with android Api level 30 after that click on the api level drop list api level 31 to 33 should show up in the list
    Now select highest api level as api level 33 and then click build it will show those api level are not available do you want to download, click download and let it download and then continue to build note: avoid Unity 2021 series it has bugs that won’t make Apk install or it will crash on start upgrade straight to Unity 2022.1.22f1
     
  4. dtootill

    dtootill

    Joined:
    Oct 9, 2020
    Posts:
    21
    Thanks for the quick responses! They allowed me to resolve the problem, which turned out to be an issue with Microsoft AppCenter.

    I took flintcheeze's advice to try API level 33, but an install built from this API still got the package parse error. Voxel-Busters asked for the error message, clearly meaning something other than the message that's the title of this thread. I did some research into a way to show messages logged into the phone itself and found adb and specifically its logcat command to display the Android log from a USB-attached device. The log showed the package parse error, with the following message shortly before it:

    AppIntegrityManagerServiceImpl: com.android.server.pm.PackageManagerException: /data/app/vmdl2130860901.tmp/base.apk (at Binary XML file line #163): com.microsoft.appcenter.distribute.DeepLinkActivity: Targeting S+ (version 31 and above) requires that an explicit value for android:exported be defined when intent filters are present​

    I found a StackOverflow page (https://stackoverflow.com/questions...e-requires-that-an-explicit-value-for-android) describing an AndroidManifest edit to address this issue directly. However, the message references appcenter, and I figured I'd first try simply removing it from the project. This worked, and I now have a working build from API Level 33. Thanks again for your help.
     
    Voxel-Busters likes this.
  5. flintcheeze

    flintcheeze

    Joined:
    Sep 10, 2015
    Posts:
    80
    Glad your issue has been fixed
     
  6. theReal3omda

    theReal3omda

    Joined:
    Oct 19, 2021
    Posts:
    1
    Same issue. What file did you delete? and where to find it ?
     
  7. dtootill

    dtootill

    Joined:
    Oct 9, 2020
    Posts:
    21
    I deleted Assets/AppCenter - in other words, simply removed the AppCenter package completely, as it wasn't particularly important to my game. If it is important to yours, you'll need to take one of the approaches cited in my 2020-10-09 post.
     
  8. Younes1951

    Younes1951

    Joined:
    Mar 24, 2023
    Posts:
    2
    I have this problems but i don't unterstand yet good plz any one can help to open that problems he stop me in many games
     
  9. Voxel-Busters

    Voxel-Busters

    Joined:
    Feb 25, 2015
    Posts:
    1,828
    If you get "App not installed", you need to share here what actually is the complete error. You can get the log by installing the apk via adb command in terminal.

    Without proper details/log info no one can help as it just leads to lots of assumptions.
     
  10. Younes1951

    Younes1951

    Joined:
    Mar 24, 2023
    Posts:
    2
    when install the app in my phone . he installed normally but when i try opened showing this.
     

    Attached Files:

    Last edited: Sep 24, 2023
  11. Voxel-Busters

    Voxel-Busters

    Joined:
    Feb 25, 2015
    Posts:
    1,828
    Yes, got that. What I'm looking for is the error message (most likely he is on a higher os version). The error message is more dev friendly if the apk is installed from adb command.