Unity Admob v6.1.0 - "You are trying to create a MonoBehaviour using the 'new' keyword" Warning

Viewed 1962

this is the warning when I run the game

enter image description here

You are trying to create a MonoBehaviour using the 'new' keyword. This is not allowed. MonoBehaviours can only be added using AddComponent(). Alternatively, your script can inherit from ScriptableObject or no base class at all UnityEngine.MonoBehaviour:.ctor () ButtonBehaviour:.ctor () GoogleMobileAds.Unity.InterstitialClient:CreateButtonBehavior () GoogleMobileAds.Unity.InterstitialClient:Show () GoogleMobileAds.Api.InterstitialAd:Show () AdManager:ShowInterstitialAd () (at Assets/Scripts/AdManager.cs:114) GameManager:GameOver () (at Assets/Scripts/GameManager.cs:174) GameManager:UpdateLives (int) (at Assets/Scripts/GameManager.cs:148) Target:ReverseHeartAnimation () (at Assets/Scripts/Target.cs:99) Target:OnTriggerEnter (UnityEngine.Collider) (at Assets/Scripts/Target.cs:66)

My problem is very similar with this: https://answers.unity.com/questions/1804626/google-admob-reklamlar%C4%B1n%C4%B1-kullanam%C4%B1yorum.html

I am able to run my game and see test ads in computer but when I upload my bundle to play store it crashes and doesn't even open. Since I don't get any errors I suspect from ads. Somebody in groups said that:

"The problem at the line buttonBehaviour = new ButtonBehaviour(); 
in CreateButtonBehavior function
in Assets\GoogleMobileAds\Platforms\Unity\BannerClient.cs

I  replaced line buttonBehaviour = new ButtonBehaviour(); 
with lines:
           GameObject ob=new GameObject();
            ob.AddComponent<ButtonBehaviour>();
            buttonBehaviour = ob.GetComponent<ButtonBehaviour>();

And warning gone."

However, I don't have "\Platforms\Unity\BannerClient.cs" and I don't have BannerClient.cs in anywhere. I think it's due to my GoogleMobileAds version.

enter image description here

I wanted to downgrade my GoogleMobileAds version but I thought deleting current files may cause more problem. That's why I wrote here first.

Does anyone know the solution of the problem? Experienced earlier?

0 Answers
Related