Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Bug ANDROID Ads not working: Error handling invocation when using minification

Discussion in 'Unity Mediation' started by BBO_Lagoon, Oct 20, 2022.

  1. BBO_Lagoon

    BBO_Lagoon

    Joined:
    Mar 2, 2017
    Posts:
    170
    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:

    Code (CSharp):
    1. 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:

    Code (CSharp):
    1. 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 ;)


    [EDIT]
    Tested on iOS an all is working.
    Tested with rewarded on Android and the problem stays the same.
     
    Last edited: Oct 20, 2022
  2. BBO_Lagoon

    BBO_Lagoon

    Joined:
    Mar 2, 2017
    Posts:
    170
    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 ?
     
    uranaka likes this.
  3. uranaka

    uranaka

    Joined:
    Jul 14, 2021
    Posts:
    1
    I, too,would like to know Proguard rules.
    Anyone,Please tell me!
     
    Last edited: Nov 3, 2022
  4. Evgeno

    Evgeno

    Joined:
    Sep 8, 2014
    Posts:
    15
    Also ran into this problem. No ads work with minification enabled. Why is that? And how much will I lose by not including minification?
     
  5. ap-unity

    ap-unity

    Unity Technologies

    Joined:
    Aug 3, 2016
    Posts:
    1,503
  6. BBO_Lagoon

    BBO_Lagoon

    Joined:
    Mar 2, 2017
    Posts:
    170
    Hi,
    I tried with the SDK 4.4.1 and the problem is still the same, Ads not working when enabling minification.
     
  7. BBO_Lagoon

    BBO_Lagoon

    Joined:
    Mar 2, 2017
    Posts:
    170
    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 ?
     
  8. BBO_Lagoon

    BBO_Lagoon

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