UnityAds WebViewApp.java is throwing OutOfMemoryError and crashing my game

Hi folks, I’m having some issues with the UnityAds SDK, the class WebViewApp is throwing a java.lang.OutOfMemoryError from 3 different lines 120, 130 and 131, highlighted below:


You can also check the full code here.

And below you also can check the crash logs captured by Crashlytics:



Do you guys have any idea if I can mitigate this issue from my side? Or do I have to wait for an UnityAds SDK new version to fix this issue?

Which version of the Ads SDK are you using? Are you seeing this error on multiple devices or are you using a specific device?

I’m using the UnityAds version 3.5.1 (Release Unity Ads 3.5.1 · Unity-Technologies/unity-ads-android · GitHub) on Android, the game is targeting the Android API 29 and below you can check the range of device models:

  • LG Stylus3
  • moto g(8) play
  • LG K40S
  • Galaxy A10
  • Galaxy Tab A
  • Galaxy J3(2017)
  • LG Stylo 6
  • Galaxy J5(2016)
  • moto g(7) play
  • LG K9
  • Galaxy Grand Prime Plus
  • Galaxy Tab A 8.0
  • moto g fast
  • moto e
  • Galaxy Tab E 9.6
  • LG LM-X525
  • LG Stylo 3 Plus
  • LG K8(2018)
  • Galaxy J2
  • LG Aristo 4+
  • HTC Desire 650
  • Galaxy S5 Neo

Maybe, changing the line 119 from this private void invokeJavascriptMethod(String className, String methodName, JSONArray params) throws JSONException { to this private void invokeJavascriptMethod(String className, String methodName, JSONArray params) throws JSONException, OutOfMemoryError {, will hold the exception inside the try/catch here and solve the issue?

From looking at the specs of those devices they all seem to be fairly low power. Most of them have <2gb ram. From the logs you posted the issue simply seems to be that those devices are actually out of memory, and therefore the Ads SDK isn’t able to allocate the memory it needs to perform correctly.

We have seen this error before and typically the issue is due to the developer’s app using too much memory and not leaving enough for the Ads SDK. I would recommend trying to update to the latest version of our SDK and if that fails, you might have some success addressing your app’s overall memory usage.

I receive this error on iPhoneX while watching Unity ADS but not on iPad

@vitaliano_fanatee we are also getting this crash with unity ads disabled , is there any fix for this ?