Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only. On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live. Read our full announcement for more information and let us know if you have any questions.

Bug Play Asset Delivery: SecurityException on Android 14

Discussion in 'Android' started by Enormus, Oct 19, 2023.

  1. Enormus

    Enormus

    Joined:
    Jul 24, 2022
    Posts:
    8
    Using Unity 2021.3.28f1 the com.unity3d.player.PlayAssetDeliveryUnityWrapper.registerDownloadStatusListener module is throwing "SecurityException: One of RECEIVER_EXPORTED or RECEIVER_NOT_EXPORTED should be specified when a receiver isn't being registered exclusively for system broadcasts" on Android 14 when targeting Android API 34." Attached is a stack trace. Is this fixed in a newer 2021 release and/or is a fix in the works? All that is required is to add of the parameters such as:

    "Intent intent = _activity.registerReceiver(BluetoothReceiver, filter, android.content.Context.RECEIVER_NOT_EXPORTED);"
     

    Attached Files:

  2. IGuscin

    IGuscin

    Unity Technologies

    Joined:
    May 12, 2022
    Posts:
    117
    Issue is coming from
    'com.google.android.play:asset-delivery:2.0.0' package. As a workaround you can try exporting your project, modify build.gradle
    (changing from
    implementation 'com.google.android.play:asset-delivery:2.0.0'
    to
    implementation 'com.google.android.play:asset-delivery:2.1.0')
    and building from Android Studio.
    Or another option - enable Custom Main Gradle template in Player -> Publishing settings and add
    implementation 'com.google.android.play:asset-delivery:2.1.0' to the dependencies section
     
  3. Enormus

    Enormus

    Joined:
    Jul 24, 2022
    Posts:
    8
    @IGuscin thank you for the suggestion. Unfortunately, changing to version 2.1.0 results in an immediate crash on startup. I've attached the crash stack trace
     

    Attached Files:

  4. VoxGuy

    VoxGuy

    Joined:
    Jul 30, 2013
    Posts:
    22
    Hi all,

    Any update on this ?

    Fab
     
  5. HarryCodder

    HarryCodder

    Joined:
    Feb 20, 2015
    Posts:
    85
    We're getting the same problem with the latest 2020.3 release when building an android AAB bundle with "split application binary" enabled (to generate embedded asset packs).
    As stated before, the solution provided here doesn't work for multiple reasons:
    • the "com.google.android.play:asset-delivery" library is not in the dependencies of the build.gradle file in Unity 2020 or 2021, instead the older "com.google.android.play:core" is. And you can't just replace one with the other without also altering the native android player code...
      This essentially replaces a problem with another.
    • the exception is clearly thrown from native android player code not meeting the API requirements. Unless the newer versions of this API reverted those requirements, the provided solution has no chance to work.
    As of now, building an Android AAB app targetting Android 14 (API 34) using Unity 2020 or 2021 is impossible if you also want to use embedded asset packs by enabling the "split application binary" option.
     
    Last edited: Nov 20, 2023
  6. RuslanMag_13

    RuslanMag_13

    Joined:
    Nov 6, 2018
    Posts:
    1
    Hello all,
    Any updates?
     
  7. IGuscin

    IGuscin

    Unity Technologies

    Joined:
    May 12, 2022
    Posts:
    117
    As far as I can see the fix has already landed and should be available in 2021.3.34f1 and 2022.3.14f1
     
    RuslanMag_13 and NurGamesStudio like this.
  8. MaxxRafen

    MaxxRafen

    Joined:
    Apr 7, 2014
    Posts:
    32
    The most recent version of 2021 that I see is Unity 2021.3.33f1. This version still has the crash issue.
     
  9. IGuscin

    IGuscin

    Unity Technologies

    Joined:
    May 12, 2022
    Posts:
    117
    I'm not sure what's the release timeframe, but the fix has landed and should be in 2021.3.34f1
     
    Sheeks likes this.
  10. claudiosdafonso

    claudiosdafonso

    Joined:
    Jun 6, 2023
    Posts:
    3
    When will 2021.3.34f1 arrive?
     
    RuslanMag_13 likes this.
  11. Sheeks

    Sheeks

    Joined:
    Jun 9, 2017
    Posts:
    12
    Still persists in 2021.3.34f1 - working on Android 13 but not on 14. Any suggestions?
    Working with 2022.3.17f1 on Android 14!
     
    Last edited: Jan 17, 2024
  12. IGuscin

    IGuscin

    Unity Technologies

    Joined:
    May 12, 2022
    Posts:
    117
    Can you share a repro project? It might be another issue (same issue, caused by different lib, package etc.)
     
  13. llFlexford

    llFlexford

    Joined:
    Jan 21, 2022
    Posts:
    27
    My case with crash:
    1. Unity 2021.3.34
    2. Build with options:
    2.1. Build App Bundle
    2.2. minimum api 22
    2.3. target api 33 or 34
    3. Upload app to google console(because build *.aab)
    4. Donwload and start app on Android 14
    5. Crash
     

    Attached Files:

  14. IGuscin

    IGuscin

    Unity Technologies

    Joined:
    May 12, 2022
    Posts:
    117
    I cannot say anything without an repro project. We're unable to reproduce the issue. Only a wild guess - did you enable split app binary?
     
  15. llFlexford

    llFlexford

    Joined:
    Jan 21, 2022
    Posts:
    27
    Ok I made sample project: https://drive.google.com/file/d/11uNFiTrhFTU2qz1nPVmBSIu_R4A2HmWm/view?usp=sharing
    Also i made build: https://drive.google.com/file/d/1coJeJjdaEThrdeOwn34xxbsl251Vtk7Q/view?usp=sharing

    For build use menu: MVP -> 1) Build App
    For install use menu: MVP -> 2) Install build
    For change build params use script BuildTool.cs
     
  16. paljan

    paljan

    Joined:
    Feb 9, 2015
    Posts:
    32
    I'd like to jump in here and ask should the fix also work for split binary then? We're under the same belief as HarryCoder explained earlier here: Play Asset Delivery: SecurityException on Android 14
     
  17. IGuscin

    IGuscin

    Unity Technologies

    Joined:
    May 12, 2022
    Posts:
    117
    As far as I know 2020.3 is no longer supported, so I wouldn't expect fix to land there. For 2021.3 - fix was actually targeting this specific case. Crash was occurring in Google 'com.google.android.play:asset-delivery:2.0.0' package, so the fix was to bump package version in 2022.3 and above Unity versions and to replace obsolete com.google.android.play:core package in 2021.3
     
    garibong and paljan like this.
  18. IGuscin

    IGuscin

    Unity Technologies

    Joined:
    May 12, 2022
    Posts:
    117
    Maybe I'm missing something? I've downloaded your sample project, opened using Unity 2021.3.35f1, specified signing key, built using MVP->Build, uploaded to the Play Store Internal testing track, downloaded to the Pixel 6 Pro Android 14 device. No crash occurred. Seeing empty scene with Build ID in the bottom
     
  19. llFlexford

    llFlexford

    Joined:
    Jan 21, 2022
    Posts:
    27
    I did sample for 2021.3.34f1, idk, may be it's required...
    Also google store isn't required, I can reproduce crash just use adb or bundletool commands for instal apk or aab to my device.
    May be need specific device OS, my device is oneplus 10 pro, OS - OxygenOS 14.0
     
  20. IGuscin

    IGuscin

    Unity Technologies

    Joined:
    May 12, 2022
    Posts:
    117
    I believe I might know where's the problem. As far as I can see you've added to the Main Gradle Template

    configurations.all {
    exclude group:"com.google.android.play", module: "core"
    }

    And your app crash with exception: java.lang.NoSuchMethodError: No interface method getPackStates(Ljava/util/List;)Lcom/google/android/play/core/tasks/Task;
     
  21. llFlexford

    llFlexford

    Joined:
    Jan 21, 2022
    Posts:
    27
    If I remove custom implementations and exclude I have crash

    upload_2024-2-14_7-44-45.png

    Code (CSharp):
    1. 2024-02-14 07:42:38.560   947-947   DEBUG                   pid-947                              A  Process name is com.Crash.CrashTest, not key_process
    2. 2024-02-14 07:42:38.560   947-947   DEBUG                   pid-947                              A  Cmdline: com.Crash.CrashTest
    3. 2024-02-14 07:42:38.560   947-947   DEBUG                   pid-947                              A  pid: 31716, tid: 883, name: UnityMain  >>> com.Crash.CrashTest <<<
    4. 2024-02-14 07:42:38.560   947-947   DEBUG                   pid-947                              A  Abort message: 'No pending exception expected: java.lang.SecurityException: com.Crash.CrashTest: One of RECEIVER_EXPORTED or RECEIVER_NOT_EXPORTED should be specified when a receiver isn't being registered exclusively for system broadcasts
    5.                                                                                                       at java.lang.Exception android.os.Parcel.createExceptionOrNull(int, java.lang.String) (Parcel.java:3087)
    6.                                                                                                       at java.lang.Exception android.os.Parcel.createException(int, java.lang.String) (Parcel.java:3071)
    7.                                                                                                       at void android.os.Parcel.readException(int, java.lang.String) (Parcel.java:3054)
    8.                                                                                                       at void android.os.Parcel.readException() (Parcel.java:2996)
    9.                                                                                                       at android.content.Intent android.app.IActivityManager$Stub$Proxy.registerReceiverWithFeature(android.app.IApplicationThread, java.lang.String, java.lang.String, java.lang.String, android.content.IIntentReceiver, android.content.IntentFilter, java.lang.String, int, int) (IActivityManager.java:5684)
    10.                                                                                                       at android.content.Intent android.app.ContextImpl.registerReceiverInternal(android.content.BroadcastReceiver, int, android.content.IntentFilter, java.lang.String, android.os.Handler, android.content.Context, int) (ContextImpl.java:1860)
    11.                                                                                                       at android.content.Intent android.app.ContextImpl.registerReceiver(android.content.BroadcastReceiver, android.content.IntentFilter, java.lang.String, android.os.Handler) (ContextImpl.java:1796)
    12.                                                                                                       at android.content.Intent android.app.ContextImpl.registerReceiver(android.content.BroadcastReceiver, android.content.IntentFilter) (ContextImpl.java:1784)
    13.                                                                                                       at android.content.Intent android.content.ContextWrapper.registerReceiver(android.content.BroadcastReceiver, android.content.IntentFilter) (ContextWrapper.java:765)
    14.                                                                                                       at void com.google.android.play.core.listener.b.b() ((null):-1)
    15.                                                                                                       at void com.google.android.play.core.listener.b.f(com.google.android.play.core.listener.StateUpdatedListener) ((null):-1)
    16.                                                                                                       at void com.google.android.play.core.assetpacks.i.registerListener(com.google.android.play.core.assetpacks.AssetPackStateUpdateListener) ((null):-1)
    17.                                                                                                       at java.lang.Object com.unity3d.player.a.a(com.unity3d.player.IAssetPackManagerDownloadStatusCallback) ((null):-1)
    18.                                                                                                       at java.lang.Object com.unity3d.player.PlayAssetDeliveryUnityWrapper.registerDownloadStatusListener(com.unity3d.player.IAssetPackManagerDownloadStatusCallback) ((null):-1)
    19.                                                                                                       at boolean com.unity3d.player.UnityPlayer.nativeRender() ((null):-2)
    20.                                                                                                       at boolean com.unity3d.player.UnityPlayer.access$500(com.unity3d.player.UnityPlayer) ((null):-1)
    21.                                                                                                       at boolean com.unity3d.player.UnityPlayer$e$1.handleMessage(android.os.Message) ((null):-1)
    22.                                                                                                       at void android.os.Handler.dispatchMessage(android.os.Message) (Handler.java:102)
    23.                                                                                                       at boolean android.os.Looper.loopOnce(android.os.Looper, long, int) (Looper.java:257)
    24.                                                                                                       at void android.os.Looper.loop() (Looper.java:368)
    25.                                                                                                       at void com.unity3d.player.UnityPlayer$e.run() ((null):-1)
    26.                                                                                                     Caused by: android.os.RemoteException: Remote stack trace:
    27.                                                                                                         at com.android.server.am.ActivityManagerService.registerReceiverWithFeature(ActivityManagerService.java:14845)
    28.                                                                                                         at android.app.IActivityManager$Stub.onTransact(IActivityManager.java:2570)
    29.                                                                                                         at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:2985)
    30.                                                                                                         at android.os.Binder.execTransactInternal(Binder.java:1387)
    31.                                                                                                         at android.os.Binder.execTransact(Binder.java:1299)
    32.                                                                                                    
    33.                                                                                                     (Throwable with no stack trace)'
    34. 2024-02-14 07:42:38.560   947-947   DEBUG                   pid-947                              A        #10 pc 000000000004f602  /data/app/~~q4Y9q2k86xar5yP5y9Yt6A==/com.Crash.CrashTest-uHnHK1dDeatvXPsO4Ziv0w==/oat/arm64/base.vdex (com.unity3d.player.PlayAssetDeliveryUnityWrapper.getAssetPackState+2)
    35. 2024-02-14 07:42:38.560   947-947   DEBUG                   pid-947                              A        #14 pc 00000000002a6964  /data/app/~~q4Y9q2k86xar5yP5y9Yt6A==/com.Crash.CrashTest-uHnHK1dDeatvXPsO4Ziv0w==/lib/arm64/libunity.so (BuildId: 0b07352f1d0001272875c9fc29f0b35edc5e5a5a)
    36. 2024-02-14 07:42:38.560   947-947   DEBUG                   pid-947                              A        #15 pc 00000000002b8f84  /data/app/~~q4Y9q2k86xar5yP5y9Yt6A==/com.Crash.CrashTest-uHnHK1dDeatvXPsO4Ziv0w==/lib/arm64/libunity.so (BuildId: 0b07352f1d0001272875c9fc29f0b35edc5e5a5a)
    37. 2024-02-14 07:42:38.560   947-947   DEBUG                   pid-947                              A        #16 pc 00000000002b8ce8  /data/app/~~q4Y9q2k86xar5yP5y9Yt6A==/com.Crash.CrashTest-uHnHK1dDeatvXPsO4Ziv0w==/lib/arm64/libunity.so (BuildId: 0b07352f1d0001272875c9fc29f0b35edc5e5a5a)
    38. 2024-02-14 07:42:38.560   947-947   DEBUG                   pid-947                              A        #17 pc 00000000002bb798  /data/app/~~q4Y9q2k86xar5yP5y9Yt6A==/com.Crash.CrashTest-uHnHK1dDeatvXPsO4Ziv0w==/lib/arm64/libunity.so (BuildId: 0b07352f1d0001272875c9fc29f0b35edc5e5a5a)
    39. 2024-02-14 07:42:38.560   947-947   DEBUG                   pid-947                              A        #18 pc 00000000002bcf58  /data/app/~~q4Y9q2k86xar5yP5y9Yt6A==/com.Crash.CrashTest-uHnHK1dDeatvXPsO4Ziv0w==/lib/arm64/libunity.so (BuildId: 0b07352f1d0001272875c9fc29f0b35edc5e5a5a)
    40. 2024-02-14 07:42:38.560   947-947   DEBUG                   pid-947                              A        #19 pc 00000000002d29a8  /data/app/~~q4Y9q2k86xar5yP5y9Yt6A==/com.Crash.CrashTest-uHnHK1dDeatvXPsO4Ziv0w==/lib/arm64/libunity.so (BuildId: 0b07352f1d0001272875c9fc29f0b35edc5e5a5a)
    41. 2024-02-14 07:42:38.560   947-947   DEBUG                   pid-947                              A        #22 pc 0000000000051ed8  /data/app/~~q4Y9q2k86xar5yP5y9Yt6A==/com.Crash.CrashTest-uHnHK1dDeatvXPsO4Ziv0w==/oat/arm64/base.vdex (com.unity3d.player.UnityPlayer.access$500+0)
    42. 2024-02-14 07:42:38.560   947-947   DEBUG                   pid-947                              A        #24 pc 00000000000514f8  /data/app/~~q4Y9q2k86xar5yP5y9Yt6A==/com.Crash.CrashTest-uHnHK1dDeatvXPsO4Ziv0w==/oat/arm64/base.vdex (com.unity3d.player.UnityPlayer$e$1.handleMessage+252)
    43. 2024-02-14 07:42:38.560   947-947   DEBUG                   pid-947                              A        #29 pc 00000000000518f4  /data/app/~~q4Y9q2k86xar5yP5y9Yt6A==/com.Crash.CrashTest-uHnHK1dDeatvXPsO4Ziv0w==/oat/arm64/base.vdex (com.unity3d.player.UnityPlayer$e.run+40)
    44.  
     
  22. llFlexford

    llFlexford

    Joined:
    Jan 21, 2022
    Posts:
    27
    If I add asset-packs implementation for version 2.1.0 i can't build app
    Screenshot_7.png

    Screenshot_6.png
     
  23. IGuscin

    IGuscin

    Unity Technologies

    Joined:
    May 12, 2022
    Posts:
    117
    If we're talking about the sample repro project - you can try just to backup all the templates, remove existing ones and enable these again. That would create a clean, up to date version of templates. Asset delivery package will be automatically added when building/exporting project with Split app binary + build AAB enabled, so no need to add that implementation manually.
    I'm able to build and run your project without any issues.
    There is also a chance that some of your plugins are adding similar dependencies. You could try updating these, resolving conflicts using EDM4U
     
  24. llFlexford

    llFlexford

    Joined:
    Jan 21, 2022
    Posts:
    27
    Ok, I did changes:
    *. Use unity 2021.3.34f1
    1. Disabled all custom gradle templates and android manifest
    2. Enabled Split Application Binary
    3. EDM4U -> Android Force Resolve
    4. Toolbar menu -> MVP -> Build App
    5. Toolbar menu -> MVP -> Install build
    6. Started app on my device: Oneplus 10 pro, OxygenOS 14.0
    7. !!!!!!!!!!!!!!!!!!!!!!!Crash!!!!!!!!!!!!!!!!!!!!!!!



    Sample project with current state: https://drive.google.com/file/d/1zOFPH3r1jQxzyPROqtPFRD1B9r2CKNHq/view?usp=sharing
    Тhere is last build by path '/Builds/build_16', you can install it.
     

    Attached Files:

  25. IGuscin

    IGuscin

    Unity Technologies

    Joined:
    May 12, 2022
    Posts:
    117
    Were you able to repro the crash using that sample project, not the full one? I've both installed your build_16 and built locally. In both cases no crash occurred. Used 2021.3.34f1
     
  26. llFlexford

    llFlexford

    Joined:
    Jan 21, 2022
    Posts:
    27
    Yes I have crash with build_16.
    I think you need check other devices, not only google pixel...
     
  27. IGuscin

    IGuscin

    Unity Technologies

    Joined:
    May 12, 2022
    Posts:
    117
    I've tested with couple other devices and was able to repro crash using build provided by you. But going through steps I've suggested before - build is working fine.
    1) Disable all the templates
    2) Do a backup of these
    3) Rename/remove all the templates from Plugins/Android folder
    4) Enable needed templates
    5) EDM4U -> Resolve
    6) MVP -> Build
    7) MVP -> Install

    Also, try removing Library folder from your project location, might be that some of the dependencies were cached, thus causing crash.
    And might be that crash is caused by some of the plugins/dependencies in your project, that doesn't exist in the stripped repro project
     
  28. HarryCodder

    HarryCodder

    Joined:
    Feb 20, 2015
    Posts:
    85
    I got some time to test my very minimal repro project which had the crash.
    Using Unity 2021.3.35f1, it doesn't crash anymore.
     
    Franciscotx56 likes this.
  29. IGuscin

    IGuscin

    Unity Technologies

    Joined:
    May 12, 2022
    Posts:
    117
    Glad to hear that! :)
    Actually it shouldn't crash starting with 2021.3.34f1, I'm not aware of any changes between 34 and 35 that might affect that
     
  30. unity_2449251A1C874D7D5181

    unity_2449251A1C874D7D5181

    Joined:
    Sep 27, 2021
    Posts:
    1
    The game was crashing on Android right after opening it. A solution was found on this page. It happned because Unity 2021.3.34f1 was build using Play Asset Delivery 2.1.0 and that caused the error below:

    Code (csharp):
    1. Abort message: 'JNI DETECTED ERROR IN APPLICATION: JNI NewStringUTF called with pending exception
    2. java.lang.NoSuchMethodError: No interface method getPackStates(Ljava/util/List;)Lcom/google/android/gms/tasks/Task;
    3. in class Lcom/google/android/play/core/assetpacks/AssetPackManager; or its super classes
    4. (declaration of 'com.google.android.play.core.assetpacks.AssetPackManager'
    5. appears in /data/app/com.*****/base.apk)
    To fix that, we would need to add the package com.google.android.play:asset-delivery:2.0.2 as dependency on Gradle, although that caused a duplicate class because of Play Core already contains some of the same classes. The solution shown in the link above tells to include this empty monolithic Play Core library as a local maven repository, then we need to Resolve the dependencies on Unity.
     
  31. IGuscin

    IGuscin

    Unity Technologies

    Joined:
    May 12, 2022
    Posts:
    117
    com.google.android.play:asset-delivery:2.0.2 Would crash with Target API 34 launched on Android 14 with Broadcast receiver Exported/Not_exported flag missing. That's the reason behind this update
     
  32. karthick_highbrow

    karthick_highbrow

    Joined:
    Jan 15, 2016
    Posts:
    3
    How to fix this I stuck for long time. I am latest version unity 2024.3.20f1 .please help me to fix this issue.when download complete that time crashed in Android 14
     
  33. a274090141

    a274090141

    Joined:
    Oct 13, 2021
    Posts:
    1
    Have you solved this problem? I'm facing this problem now, it's a headache