Closed AntonPetrov83 closed 2 years ago
I'm seeing a lot of this crash too (in Play Console) and always on Android 7.0
@dhamelin I have included com.unity.mobile.notifications source files to the project and added try-catch here:
protected static Notification.Builder recoverBuilder(Context context, Notification notification) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
try {
Notification.Builder builder = Notification.Builder.recoverBuilder(context, notification);
// extras not recovered, transfer manually
builder.setExtras(notification.extras);
return builder;
} catch (Exception e) {
Log.e(TAG_UNITY, "Failed to recover builder", e);
} catch (OutOfMemoryError e) {
Log.e(TAG_UNITY, "Failed to recover builder", e);
}
return null;
}
else {
return recoverBuilderPreNougat(context, notification);
}
}
I will confirm that it works in Production in a couple of days.
Same issues for my users, common conditions: Android 7 & Device Vendor: Samsung
java.lang.RuntimeException:
at android.app.ActivityThread.handleReceiver (ActivityThread.java:3366)
at android.app.ActivityThread.-wrap20 (ActivityThread.java)
at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1723)
at android.os.Handler.dispatchMessage (Handler.java:102)
at android.os.Looper.loop (Looper.java:154)
at android.app.ActivityThread.main (ActivityThread.java:6780)
at java.lang.reflect.Method.invoke (Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:1496)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1386)
Caused by: android.content.res.Resources$NotFoundException:
at android.app.ResourcesManager.createAssetManager (ResourcesManager.java:281)
at android.app.ResourcesManager.createResourcesImpl (ResourcesManager.java:359)
at android.app.ResourcesManager.getOrCreateResources (ResourcesManager.java:638)
at android.app.ResourcesManager.getResources (ResourcesManager.java:730)
at android.app.ActivityThread.getTopLevelResources (ActivityThread.java:2049)
at android.app.LoadedApk.getResources (LoadedApk.java:787)
at android.app.ContextImpl.
@dhamelin I have included com.unity.mobile.notifications source files to the project and added try-catch here:
protected static Notification.Builder recoverBuilder(Context context, Notification notification) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { try { Notification.Builder builder = Notification.Builder.recoverBuilder(context, notification); // extras not recovered, transfer manually builder.setExtras(notification.extras); return builder; } catch (Exception e) { Log.e(TAG_UNITY, "Failed to recover builder", e); } catch (OutOfMemoryError e) { Log.e(TAG_UNITY, "Failed to recover builder", e); } return null; } else { return recoverBuilderPreNougat(context, notification); } }
I will confirm that it works in Production in a couple of days.
Thanks for that. I have just pushed an update including this. I will keep you posted once more players have adopted this version and have played with it a bit.
@dhamelin Hi! I confirm that this worked for us, no more crashes like that.
Also reproducible on Samsung Galaxy s8 (OS:7):
2022/06/21 15:47:34.156 5360 5423 Info Unity Unity.Notifications.Tests.Sample.SafeArea:Awake () (at /Users/vaidasm/Documents/GitHub/com.unity.mobile.notifications/TestProjects/com.unity.mobil
2022/06/21 15:47:34.435 5360 5423 Warn System ClassLoader referenced unknown path:
2022/06/21 15:47:34.435 5360 5423 Warn System ClassLoader referenced unknown path: /data/app/com.unity3d.mobilenotificationtests-1/lib/arm
2022/06/21 15:47:34.436 5360 5423 Warn linker Warning: unable to resolve "/data/app/com.unity3d.mobilenotificationtests-1/base.apk": No such file or directory
2022/06/21 15:47:34.437 5360 5423 Warn asset Asset path /data/app/com.unity3d.mobilenotificationtests-1/base.apk is neither a directory nor file (type=1).
2022/06/21 15:47:34.495 5360 5423 Error Unity AndroidJavaException: android.content.res.Resources$NotFoundException: failed to add asset path /data/app/com.unity3d.mobilenotificationtests-1/base.apk
2022/06/21 15:47:34.495 5360 5423 Error Unity android.content.res.Resources$NotFoundException: failed to add asset path /data/app/com.unity3d.mobilenotificationtests-1/base.apk
2022/06/21 15:47:34.495 5360 5423 Error Unity at android.app.ResourcesManager.createAssetManager(ResourcesManager.java:281)
2022/06/21 15:47:34.495 5360 5423 Error Unity at android.app.ResourcesManager.createResourcesImpl(ResourcesManager.java:359)
2022/06/21 15:47:34.495 5360 5423 Error Unity at android.app.ResourcesManager.getOrCreateResources(ResourcesManager.java:638)
2022/06/21 15:47:34.495 5360 5423 Error Unity at android.app.ResourcesManager.getResources(ResourcesManager.java:730)
2022/06/21 15:47:34.495 5360 5423 Error Unity at android.app.ActivityThread.getTopLevelResources(ActivityThread.java:2052)
2022/06/21 15:47:34.495 5360 5423 Error Unity at android.app.LoadedApk.getResources(LoadedApk.java:787)
2022/06/21 15:47:34.495 5360 5423 Error Unity at android.app.ContextImpl.
Fixed in master.
Still seeing this on 2.0.2 and Unity 2020.3.34f1:
java.lang.RuntimeException:
at android.app.ActivityThread.handleReceiver (ActivityThread.java:3107)
at android.app.ActivityThread.-wrap18 (ActivityThread.java)
at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1611)
at android.os.Handler.dispatchMessage (Handler.java:110)
at android.os.Looper.loop (Looper.java:203)
at android.app.ActivityThread.main (ActivityThread.java:6251)
at java.lang.reflect.Method.invoke (Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:1063)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:924)
Caused by: android.content.res.Resources$NotFoundException:
at android.app.ResourcesManager.createAssetManager (ResourcesManager.java:253)
at android.app.ResourcesManager.createResourcesImpl (ResourcesManager.java:310)
at android.app.ResourcesManager.getOrCreateResources (ResourcesManager.java:571)
at android.app.ResourcesManager.getResources (ResourcesManager.java:645)
at android.app.ActivityThread.getTopLevelResources (ActivityThread.java:1920)
at android.app.LoadedApk.getResources (LoadedApk.java:771)
at android.app.ContextImpl.<init> (ContextImpl.java:2059)
at android.app.ContextImpl.createApplicationContext (ContextImpl.java:1828)
at android.content.ContextWrapper.createApplicationContext (ContextWrapper.java:792)
at android.content.ContextWrapper.createApplicationContext (ContextWrapper.java:792)
at android.app.Notification$Builder.recoverBuilder (Notification.java:3803)
at com.unity.androidnotifications.UnityNotificationUtilities.recoverBuilder (UnityNotificationUtilities.java:517)
at com.unity.androidnotifications.UnityNotificationManager.loadSavedNotifications (UnityNotificationManager.java:519)
at com.unity.androidnotifications.UnityNotificationRestartOnBootReceiver.rescheduleSavedNotifications (UnityNotificationRestartOnBootReceiver.java:26)
at com.unity.androidnotifications.UnityNotificationRestartOnBootReceiver.onReceive (UnityNotificationRestartOnBootReceiver.java:21)
at android.app.ActivityThread.handleReceiver (ActivityThread.java:3100)
Saw some information about adding a string.xml https://stackoverflow.com/a/56461957, but this looks really outdated.
For LG (LG K10, LG K10 Power, LG G5 SE) phones with Android 7 we see:
And for HUAWEI phones with Android 7.0 too: