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

Mobile notifications are breaking android 12 builds

Discussion in 'Package Manager' started by Higaran, Jan 20, 2022.

  1. Higaran

    Higaran

    Joined:
    Jul 9, 2018
    Posts:
    3
    Hi!
    We are using Mobile Notifications package - https://github.com/Unity-Technologies/com.unity.mobile.notifications

    Currently, Google Play Console auto-rejects builds that are targeting anything lower API level 31 (Android 12). As Android 12 has updated behaviours and requires android:exported on all activities with intent filters - a lot of apps have stopped working, up to auto-uninstall on A12 without ability to reinstall (install crashes with MALFORMED_MANIFEST error)

    It took 2 days of investigation, so for Mobile Notifications team: you already have 1.4.2 release (Jul 27 2021) and commit that fixes problems with Android 12 (29 Oct 2021): https://github.com/Unity-Technologi...mmit/0916f0e546781b90bbc6b6bc62a93e9ad4dec28b.
    Please, make a new release with that commit included, as the package is really unusable as of now (20 Jan 2022).

    For anyone having problems with Android 12 builds (not installing from market, app disappearing from user devices, MALFORMED_MANIFEST errors, etc) - here's what helps:

    1) Check if you are using Custom Android Manifest in player settings. If so: find any <activity> tags with <intent-filter> inside in AndroidManifest. Add - android:exported="true" attribute for each.
    2) Try to install your app from Internal Testing or Firebase App Distribution on Android Studio emulator or real android 12 device connected via ADB. If install fails - filter ADB logs as "Errors-Only" and look for errors like

    com.unity.androidnotifications.UnityNotificationRestartOnBootReceiver: Targeting S+ (version 31 and above) requires that an explicit value for android:exported

    After finding such errors - check if you can remove or update affected packages, as they won't work on Android 12 at all.
    For those experiencing trouble with Notifications package - use fix from https://github.com/Unity-Technologi...mmit/0916f0e546781b90bbc6b6bc62a93e9ad4dec28b

    If your .gitignore ignores Packages folder, and you can't commit changes to the package - our workaround is to edit the package, repackage it and reimport as custom package from your own Registry.
     
    Voxel-Busters likes this.
  2. Voxel-Busters

    Voxel-Busters

    Joined:
    Feb 25, 2015
    Posts:
    1,828
    I see this could be problem for many until unity pushes an update. So we came up with a solution we earlier used for our plugin(Cross Platform Native Plugins : Essential Kit).

    Here is our solution on how to fix it with a simple hack.
    1. Download the attachment and export its contents
    2. Place it in Assets/Plugins/Android folder
    3. Make a build

    Basically, here we are trying to replace the existing entry and adding android:exported flag. Hope this is helpful!

    Cheers,
    VB Team
     

    Attached Files:

    kaway likes this.
  3. ahmedaniss

    ahmedaniss

    Joined:
    Sep 18, 2019
    Posts:
    98
    Problem Fixed here :
     
  4. mack2087

    mack2087

    Joined:
    May 3, 2020
    Posts:
    2
    You are a superstar. thanks a ton.
     
  5. Higaran

    Higaran

    Joined:
    Jul 9, 2018
    Posts:
    3
    This fixes manifest problem for projects not using mobile notifications package. It won't help if the package is used.
     
  6. kaway

    kaway

    Joined:
    Apr 13, 2018
    Posts:
    6


    hello, I have problems playing an exported apk on android less than 11, I don't know why, I would appreciate it if you could help me
    the game is installed in lower versions of android 11 but it does not let you start it, not even from the same playstore
     
  7. Voxel-Busters

    Voxel-Busters

    Joined:
    Feb 25, 2015
    Posts:
    1,828
    Recent release notes related to Mobile notifications mentions that the issue got fixed. Did you try their recent update?

    However, for me to find out the reason, I need either of these below
    1. Empty apk (no need of adding any scenes) or
    2. Merged manifest file post making an apk (it will be available inside nested folders of Temp after building apk)
     
  8. edinho09

    edinho09

    Joined:
    Nov 19, 2019
    Posts:
    17
  9. Wormy76

    Wormy76

    Joined:
    Sep 16, 2014
    Posts:
    3
    Hi All.

    I am having issues with Mobile Notification 2.0.2 and Android 12. All scheduled local notifications are delayed.

    Push notification tardiness ranges from a few minutes to a number of hours.

    The Push notifications work perfectly on Android 11 and lower.

    I thought it might be the way I was building the notifications. So I tested using the Mobile Notification sample scenes.
    Same issue.

    Has anyone else run into this problem?

    Any help would be greatly appreciated
     
  10. Voxel-Busters

    Voxel-Busters

    Joined:
    Feb 25, 2015
    Posts:
    1,828
    Shared info is applicable irrespective of the plugin used.

    Starting Android 12, it's not directly possible to schedule at exact time. This is because of the behavioural changes introduced in Android 12.

    The plugin you use need to provide an option to use exact alarm via a permission. Have a look here about the documentation regarding this.

    AFAIK, I think games may not fall under the category who can use this permission as google may control it at some point as they have restrictions on what kind of apps need to use this permission.
     
    Last edited: Sep 27, 2022
  11. AGaming

    AGaming

    Joined:
    Dec 26, 2013
    Posts:
    100
    Hi, thanks for your script, for 2018 Unity it helped. But here projects on 2017.4.39f gives such an error.

    Assets/Editor/AndroidManifestPostProcessor.cs(11,49): error CS0246: The type or namespace name `IPostGenerateGradleAndroidProject' could not be found. Are you missing an assembly reference?
     
  12. Voxel-Busters

    Voxel-Busters

    Joined:
    Feb 25, 2015
    Posts:
    1,828
    This was added in 2018!
     
  13. AGaming

    AGaming

    Joined:
    Dec 26, 2013
    Posts:
    100
    Is there an option how to get around the problem with Android 12 on Google Play on the Unity 2017 version?

    Thanks in advance for any advice.
     
  14. Voxel-Busters

    Voxel-Busters

    Joined:
    Feb 25, 2015
    Posts:
    1,828
    Please check this.
     
  15. AGaming

    AGaming

    Joined:
    Dec 26, 2013
    Posts:
    100
    Thanks, I'll try.
     
  16. VoldemortEatsBurgers

    VoldemortEatsBurgers

    Joined:
    Jun 28, 2021
    Posts:
    6
    Hi all! I also encountered the problem described above. All the solutions that I saw in the discussions of this problem did not help me. The source of the problem was the Unity Mobile Notifications plugin.
    I was helped by updating this plugin to the latest version. If the source of your problem is the same as mine, go to the Package Manager, find this plugin and update. Do the build itself NOT with a custom manifest.
    Good luck and I hope my advice helps someone! :)
    Note: my version of Unity is 2021.2.5f1
     
    elaine_unity694 likes this.
  17. elaine_unity694

    elaine_unity694

    Joined:
    Oct 12, 2020
    Posts:
    26
    May I know your mobile notification version please?