Search Unity

Bug Crash: com.unity3d.player.g.onRequestPermissionsResult

Discussion in 'Android' started by Bogie, Dec 26, 2022.

  1. Bogie

    Bogie

    Joined:
    Dec 2, 2015
    Posts:
    3
    For only devices running Android 6 (and about 2/3 of them are Samsung), we are seeing this crash when targeting API 33 (13) with a minimum level of 22 (5.1):

    Fatal Exception: java.lang.Error
    FATAL EXCEPTION [main] Unity version : 2021.3.14f1 Device model : ZTE BLADE V7 Device fingerprint: ZTE/P653A10_MX_TEL/P653A10:6.0/MRA58K/20160902.111813:user/release-keys Build Type : Release Scripting Backend : IL2CPP ABI : arm64-v8a Strip Engine Code : true

    Caused by java.lang.RuntimeException
    Failure delivering result ResultInfo{who=@android:requestPermissions:android:fragment:2, request=96489, result=-1, data=Intent { act=android.content.pm.action.REQUEST_PERMISSIONS (has extras) }} to activity {XXX.XXXXXXXX.XXXXXX/XXXXXX.MainActivity}: java.lang.IllegalArgumentException: Unknown permission: android.permission.POST_NOTIFICATIONS

    android.app.ActivityThread.deliverResults (ActivityThread.java:3929)
    android.app.ActivityThread.handleSendResult (ActivityThread.java:3972)
    android.app.ActivityThread.access$1400 (ActivityThread.java:175)
    android.app.ActivityThread$H.handleMessage (ActivityThread.java:1537)
    android.os.Handler.dispatchMessage (Handler.java:111)
    android.os.Looper.loop (Looper.java:207)
    android.app.ActivityThread.main (ActivityThread.java:5728)
    java.lang.reflect.Method.invoke (Method.java)
    com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:789)
    com.android.internal.os.ZygoteInit.main (ZygoteInit.java:679)

    Caused by java.lang.IllegalArgumentException
    Unknown permission: android.permission.POST_NOTIFICATIONS
    android.os.Parcel.readException (Parcel.java:1603)
    android.os.Parcel.readException (Parcel.java:1552)
    android.content.pm.IPackageManager$Stub$Proxy.shouldShowRequestPermissionRationale (IPackageManager.java:2703)
    android.app.ApplicationPackageManager.shouldShowRequestPermissionRationale (ApplicationPackageManager.java:527)
    android.app.Activity.shouldShowRequestPermissionRationale (Activity.java:3904)
    com.unity3d.player.g.onRequestPermissionsResult
    android.app.Activity.dispatchRequestPermissionsResultToFragment (Activity.java:6635)
    android.app.Activity.dispatchActivityResult (Activity.java:6508)
    android.app.ActivityThread.deliverResults (ActivityThread.java:3925)
    android.app.ActivityThread.handleSendResult (ActivityThread.java:3972)
    android.app.ActivityThread.access$1400 (ActivityThread.java:175)
    android.app.ActivityThread$H.handleMessage (ActivityThread.java:1537)
    android.os.Handler.dispatchMessage (Handler.java:111)
    android.os.Looper.loop (Looper.java:207)
    android.app.ActivityThread.main (ActivityThread.java:5728)
    java.lang.reflect.Method.invoke (Method.java)
    com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:789)
    com.android.internal.os.ZygoteInit.main (ZygoteInit.java:679)

    We have confirmed that android.permission.POST_NOTIFICATIONS is indeed in our AndroidManifest.xml, and this permission works for all other flavors of Android outside of Android 6.

    We are also using v2.1.0 of com.unity.mobile.notifications, and I have filed a bug within that package's Github, but I'm also posting here as this may be happening at the Unity level.
     
    sp-LeventeLajtai and cartedor like this.
  2. cartedor

    cartedor

    Joined:
    Feb 20, 2022
    Posts:
    1
    I am facing the same error with the same settings :(, any solution?
     
  3. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,735
    What is your target SDK?
    You can only request this permission when both device is running Android 13 and your applications target API level is 33. Both conditions must be true!
    If device is running older Android, id does not know anything about this permission and does not require it.
    If device is Android 13 but your app targets lower API level than 33, permission will be automatically requested by OS and your app cannot manually request it.
     
  4. sp-LeventeLajtai

    sp-LeventeLajtai

    Joined:
    Jul 11, 2019
    Posts:
    10
    Hello! Is there any update about this issue? I am facing exactly this problem right now.