UnityAds Crash on Android: NPE kotlinx.coroutines.flow.MutableStateFlow.setValue

Hello, we just launched our new game for Android and iOS built with the Unity engine (2022.3.16f1) and we started seeing this crash appearing on Crashlytics.

Have any of you experience this? Any way to fix it?

Caused by java.lang.NullPointerException: Attempt to invoke interface method ‘void kotlinx.coroutines.flow.MutableStateFlow.setValue(java.lang.Object)’ on a null object reference
at com.unity3d.ads.core.data.repository.AndroidSessionRepository$1.invokeSuspend(AndroidSessionRepository.kt:50)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:108)
at kotlinx.coroutines.internal.LimitedDispatcher$Worker.run(LimitedDispatcher.kt:115)
at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:103)
at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:584)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:793)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:697)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:684)

Here is the details from one of the devices

Fatal Exception: java.lang.Error: FATAL EXCEPTION [DefaultDispatcher-worker-3]
Unity version : 2022.3.16f1
Device model : OnePlus OnePlus8Pro
Device fingerprint: OnePlus/IN2023/OnePlus8Pro:11/QKR1.191246.002/2006701342:user/release-keys
CPU supported ABI : [x86_64, arm64-v8a, x86, armeabi-v7a, armeabi]
Build Type : Release
Scripting Backend : IL2CPP
Libs loaded from : lib/arm64
Strip Engine Code : true

@Pedroatg

Thanks for reporting this issue. We had a few people report a similar crash.

Can you confirm that you are using Unity Ads via mediation, either Unity LevelPlay or a third party mediation like AdMob or MAX, and you are on version 4.11.2?

If so, we have just released a new patch to address this issue:
https://docs.unity.com/ads/en-us/manual/Changelog#Version_4.11.3_-_released_2024-05-10

Same issue. Using Unity Ads version 4.11.2 via mediation.