Calling Reward Ads cause the game to crash and output this error :
Function SoundChannelInstance *SoundChannel::operator->() const may only be called from main thread! AppAdvisory.Ads.AAAdmob:OnAdOpeningRewarded(Object, EventArgs) System.Reflection.MonoMethod:Invoke(Object, BindingFlags, Binder, Object[], CultureInfo) System.Reflection.MethodBase:Invoke(Object, Object[]) UnityEngine.AndroidJavaProxy:Invoke(String, Object[]) UnityEngine._AndroidJNIHelper:InvokeJavaProxyMethod(AndroidJavaProxy, IntPtr, IntPtr) 12-05 18:45:13.500 28685 28685 E Unity : [ line 21] (Filename: Line: 21)
After testing the game with an empty scene (no audioSource) the Ads worked properly and i got no error, so i had to come back to my game and :
Disable All Enabled AudioSource when calling for reward Ads (must disable it, setting it to mute still crash the game) :
AudioSource[] musicSource = Object.FindObjectsOfType(typeof(AudioSource)) as AudioSource[];
for (int i = 0; i < musicSource.Length; i++) { musicSource[i].enabled = false; }
re-Enable All AudioSource when Ad is closed
For a game that has a lot more than just one audioSource for music that are dynamic and running constantly, running that FindObjectsOfType every death is really not something that i usually do, so am wondering, is everyone aware of this issue ? why is AdMob reward ads cause unity to crash when its playing Audio while every other Ad network that i used in the past doesn't ?
I have the same problem. The complete disabling of the background sound helped (pause sound does not help).
Unity 2018.1, Google Mobile Ads Unity Plugin v3.13.1.
Hi,
Calling Reward Ads cause the game to crash and output this error :
Function SoundChannelInstance *SoundChannel::operator->() const may only be called from main thread! AppAdvisory.Ads.AAAdmob:OnAdOpeningRewarded(Object, EventArgs) System.Reflection.MonoMethod:Invoke(Object, BindingFlags, Binder, Object[], CultureInfo) System.Reflection.MethodBase:Invoke(Object, Object[]) UnityEngine.AndroidJavaProxy:Invoke(String, Object[]) UnityEngine._AndroidJNIHelper:InvokeJavaProxyMethod(AndroidJavaProxy, IntPtr, IntPtr) 12-05 18:45:13.500 28685 28685 E Unity : [ line 21] (Filename: Line: 21)
After testing the game with an empty scene (no audioSource) the Ads worked properly and i got no error, so i had to come back to my game and :
AudioSource[] musicSource = Object.FindObjectsOfType(typeof(AudioSource)) as AudioSource[];
for (int i = 0; i < musicSource.Length; i++) { musicSource[i].enabled = false; }
For a game that has a lot more than just one audioSource for music that are dynamic and running constantly, running that FindObjectsOfType every death is really not something that i usually do, so am wondering, is everyone aware of this issue ? why is AdMob reward ads cause unity to crash when its playing Audio while every other Ad network that i used in the past doesn't ?
Thanks!