ANDROID Ads not working: Error handling invocation when using minification

Hi, I’m trying to add Ads into my game but I don’t get it to work on Android build, each time I call Ad.ShowAsync, I got the following error in the logcat console:

com.unity3d.services.core.webview.bridge.Invocation.nextInvocation() (line:8) :: Error handling invocation com.unity3d.services.ads.api.VideoPlayer.prepare([file:///storage/emulated/0/Android/data/*******/cache/UnityAdsCache/UnityAdsCache-5b53f297d5f7d100f6633eb45db88d58fe38e56f425c12676b6fc705400a6ad3.mp4, 1.00000000000000000000, 10000]): Attempt to invoke virtual method 'java.lang.Object java.lang.reflect.Method.invoke(java.lang.Object, java.lang.Object[])' on a null object reference

Tested on test ads too:

com.unity3d.services.core.webview.bridge.Invocation.nextInvocation() (line:8) :: Error handling invocation com.unity3d.services.ads.api.VideoPlayer.prepare([https://cdn-creatives-akamaistls-prd.acquire.unity3dusercontent.com/impact/11017/blue_test_trailer.mp4, 1.00000000000000000000, 10000]): Attempt to invoke virtual method 'java.lang.Object java.lang.reflect.Method.invoke(java.lang.Object, java.lang.Object[])' on a null object reference

On the device I’m stuck on a black screen and no callback are called.
If I click on the black screen I’m redirected on the store.
I’m testing interstitials videos ads (in case it’s related)

No problem in editor.
Will try on iOS later.

Any help appreciated :wink:

[EDIT]
Tested on iOS an all is working.
Tested with rewarded on Android and the problem stays the same.

Hi,
After more testing, the problem is related to minify, when I disable minification on the build, everything works.

I tried with to add these Proguard rules but it don’t work:

-keep class com.unity3d.ads.** { ; }
-keep class com.unity3d.services.
* { *; }

Anyone knows which Proguard rules to add to make it work with minification ?

1 Like

I, too,would like to know Proguard rules.
Anyone,Please tell me!

Also ran into this problem. No ads work with minification enabled. Why is that? And how much will I lose by not including minification?

Regarding the ProGuard errors, there were some issues with Unity Ads SDK 4.3.0 that were resolved in version 4.4.0

SDK 4.4.1 is the latest version, so that is the one we would recommend.

Hi,
I tried with the SDK 4.4.1 and the problem is still the same, Ads not working when enabling minification.

Hi,
Just found the problem, when using minification, the numeric invocation parameters are typed as java.math.BigDecimal instead of java.lang.Double so the method with the right signature is not found.
Do you think the problem can be solved on your side ?

OK found a way to fix it, just add this line in the proguard-user.txt file:
-keep class org.json.** {*;}