AppLovin / AppLovin-MAX-Cordova

MIT License
10 stars 12 forks source link

Android crash with RuntimeException #50

Closed UzverNumber47 closed 2 months ago

UzverNumber47 commented 2 months ago

MAX Plugin Version

1.1.4

Cordova Version

12.0.1

Device/Platform Info

Android 12

Current Behavior

2024-02-23 11:32:04.541 28987-28987 AndroidRuntime pid-28987 E FATAL EXCEPTION: main Process: com.mypackage.myapp, PID: 28987 java.lang.RuntimeException: Ad Unit ID 28eddebb0f7bf738 is invalid or disabled. Please make sure to use an Ad Unit ID from the MAX dashboard that is enabled and configured for the current application. For more information, see https://dash.applovin.com/documentation/mediation/max/get-started-with-max#step-2:-create-an-ad-unit at com.applovin.impl.mediation.d.f.y(SourceFile:245) at com.applovin.impl.mediation.d.f.a(SourceFile:138) at com.applovin.impl.mediation.d.f.$r8$lambda$w429SYDfaTU6QkS5SDwVBXyGyv0(Unknown Source:0) at com.applovin.impl.mediation.d.f$$ExternalSyntheticLambda1.run(Unknown Source:4) at android.os.Handler.handleCallback(Handler.java:938) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loopOnce(Looper.java:210) at android.os.Looper.loop(Looper.java:299) at android.app.ActivityThread.main(ActivityThread.java:8280) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:576) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1073) 2024-02-23 11:32:05.862 24038-25803 ActivityTaskManager system_server W Force finishing activity com.mypackage.myapp/.MainActivity 2024-02-23 11:32:05.919 24038-25793 PreloadController system_server W notify...pkgName=com.mypackage.myapp, userId=0, processName=com.mypackage.myapp, pid=28987, reason=killself 2024-02-23 11:32:06.045 24038-25836 WindowManager system_server I WIN DEATH: Window{16cc1bf u0 com.mypackage.myapp/com.mypackage.myapp.MainActivity} 2024-02-23 11:32:06.045 24038-25803 ActivityManager system_server I Process com.mypackage.myapp (pid 28987) has died: prcp TOP

Expected Behavior

Not to crash an app when an ad id is invalid or disabled.

Doing nothing is a much better option :)

How to Reproduce

Create a NEW add unit id (I used interstitial). IMPORTANT!! Everything works well for old ids Try to load an ad in the app.

Wait around 10 minutes.

App crashes.

Additional Info

No response

Lorenzo45 commented 2 months ago

Hi @UzverNumber47 - this is intended behavior. New ad units take 30-60 minutes before they can be used to load ads but I can see how this would cause confusion based on the error message. We can update the error message to specify this.

UzverNumber47 commented 2 months ago

What else I have found.

The app will crash if you

  1. DELETE Ad Unit
  2. PAUSE Ad Unit
  3. have the WRONG Ad Unit Id

It takes around 5 minutes for a plugin or sdk to understand that an Ad Unit is disabled and then CRASH your app. And I still don't understand why not suppress the exception and print a stacktrace to console like you already do here catch ( JSONException ignored ) { }

Lorenzo45 commented 2 months ago

Thanks for the feedback - we'll fix this in our next SDK release.

FYI - our SDK only throws these exceptions for debug builds. Release builds will not crash.

UzverNumber47 commented 2 months ago

Thank you, can't wait to test it out :)

Lorenzo45 commented 2 months ago

Hi @UzverNumber47 - we just released SDK 12.3.0 which fixes the crash you raised above. Our SDK will now fire the didFailToLoad callback instead of throwing an exception