Ads Crash on Android

Hey guys,
I am getting this error on some Android devices (e.g. Galaxy S8, Android 9):

Exception: No such proxy method: UnityEngine.Advertisements.Platform.Android.AndroidPlatform.onUnityAdsError(UnityEngine.AndroidJavaObject,System.String)
UnityEngine.AndroidJavaProxy.Invoke (System.String methodName, System.Object[] args) (at <00000000000000000000000000000000>:0)
UnityEngine._AndroidJNIHelper.InvokeJavaProxyMethod (UnityEngine.AndroidJavaProxy proxy, System.IntPtr jmethodName, System.IntPtr jargs) (at <00000000000000000000000000000000>:0)

I am using Unity 2018.4.14f1 and Unity Monetization Asset 3.4.1.
This is my ad-class:

using System.Collections;
using UnityEngine;
using UnityEngine.Advertisements;
using UnityEngine.Events;

public class AdManager : MonoBehaviour, IUnityAdsListener
{
    public void Initalize()
    {
        Advertisement.AddListener(this);
        Advertisement.Initialize(gameId, testMode);
    }

    public void ShowGameOverAd()
    {
        Advertisement.Show("video");
    }

    public void ShowExtraLifeAd()
    {
        Advertisement.Show("rewardedVideo");
    }

    public void OnUnityAdsReady(string placementId)
    {}

    public void OnUnityAdsDidError(string message)
    {
        Debug.Log("Error occured while trying to initialize Unity Ads: " + message);
    }

    public void OnUnityAdsDidStart(string placementId)
    {}

    public void OnUnityAdsDidFinish(string placementId, ShowResult showResult)
    {
        //my stuff
    }
}

Thanks for helping!

@kilicbatuhan1205

Thanks for reporting this issue. I have forwarded it to the engineering team and we should be able to get it fixed in a future version of the SDK.

@kilicbatuhan1205

One suggestion they have is to try deleting the Ads package completely (if downloaded from the Asset Store) or removing it from the Package Manager if installed there. And then re-installing the package.

I already tried that, no success. I disabled Strip Engine Code in the Build settings and created a link.xml to exclude UnityEngine.Advertisements from stripping. Will see if that fixes it…

Update: error still occurs

Update2: It seems like this error doesn’t really crash the app, I have 0% ANRs on Google Play and my users tell me that the app is not crashing, but the error is shown under Crashes&Exceptions in the Unity dashboard.

We’re getting the same exception reports from users, but we haven’t been able to reproduce it ourselves. Using Unity Ads 3.4.1. If Unity QA team is able to reproduce this, then it would be great to know if this Exception is causing the app to crash or misbehave. For example if ads with errors are not calling our callbacks in Unity C# script.

@ap-unity It’s been almost three weeks now and still no progress on this?

This is a warning not a crash. We are aware of it and will be releasing a fix in 3.4.2.

@sbankhead Thanks a lot.

@sbankhead Thanks for the confirmation that it’s not a crash.

Version 3.4.2 was just released on the Asset Store:

-[Android] Fix onUnityAdsError Exception: No such proxy method

Thanks!!

I’m getting this same crash on my S8+, ads version 3.4.7…

So, I was initializing the ads in a RuntimeInitializeOnLoadMethod, moving to a MonoBehaviour’s Awake in the first game scene fixes the problem. That crash doesn’t happen on BlueStacks, though.