Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Rewarded ads problem

Discussion in 'Unity Ads & User Acquisition' started by megalphax, Jun 6, 2020.

  1. megalphax

    megalphax

    Joined:
    Jan 10, 2020
    Posts:
    9
    Hello, i have this problem when the rewarded ad is finish :

    MissingReferenceException: The object of type 'AdsManager' has been destroyed but you are still trying to access it.
    Your script should either check if it is null or you should not destroy the object.
    UnityEngine.Component.GetComponent[T] () (at C:/buildslave/unity/build/Runtime/Export/Scripting/Component.bindings.cs:42)
    AdsManager.OnUnityAdsDidFinish (System.String placementId, UnityEngine.Advertisements.ShowResult showResult) (at Assets/Scripts/AdsManager.cs:71)
    UnityEngine.Advertisements.Platform+<>c__DisplayClass26_1.<Initialize>b__2 (UnityEngine.Advertisements.CallbackExecutor execute) (at Library/PackageCache/com.unity.ads@3.1.1/Runtime/Advertisement/Platform.cs:121)
    UnityEngine.Advertisements.CallbackExecutor.Update () (at Library/PackageCache/com.unity.ads@3.1.1/Runtime/Advertisement/CallbackExecutor.cs:25)

    code : https://pastebin.com/c6Wb9nuH
     
  2. megalphax

    megalphax

    Joined:
    Jan 10, 2020
    Posts:
    9
  3. kyle-unity

    kyle-unity

    Unity Technologies

    Joined:
    Jan 6, 2020
    Posts:
    336
    If you're changing scenes in your game, you might need to make sure you are calling RemoveListener from any IUnityAdsListener class when that scene is unloaded, so that the Ads SDK knows not to try and contact it again.

    For example, something like this could work:
    Code (CSharp):
    1. public void OnDestroy() {
    2. Advertisement.RemoveListener(this);
    3. }
     
    SamiOlewa and bergareyaraz like this.
  4. megalphax

    megalphax

    Joined:
    Jan 10, 2020
    Posts:
    9
    Thanks now it's working but i dont know why the ads work with the editor but not when builded :/
    upload_2020-6-8_13-13-59.png
    upload_2020-6-8_13-14-27.png
    upload_2020-6-8_13-15-15.png
    upload_2020-6-8_13-15-39.png

    and now i have 177 warnings

    (i have just upload a part)
     
  5. kyle-unity

    kyle-unity

    Unity Technologies

    Joined:
    Jan 6, 2020
    Posts:
    336
    The warning messages are indicating that there's some sort of issue with your installation of the Ads SDK. Can you try the following?
    • Select Assets > Reimport All inside the Unity Editor.
    • Remove all files relating to the Ads SDK from your project and then re-import it using the Package Manager (the latest version is 3.4.6)
    That should fix the warnings you're getting in the editor but might not fix the ads not appearing in your builds. Do you have any device logs (e.g. from Logcat) from when the app is running? Or do you have a link to a build of your game I can install?
     
  6. megalphax

    megalphax

    Joined:
    Jan 10, 2020
    Posts:
    9
  7. kyle-unity

    kyle-unity

    Unity Technologies

    Joined:
    Jan 6, 2020
    Posts:
    336
    I installed your app and played through the game. When I lost, I saw the following appear in the logs:
    Code (CSharp):
    1. 2020/06/10 12:07:02.419 22493 22515 Error Unity Initializing Unity Ads.
    2. 2020/06/10 12:07:02.419 22493 22515 Error Unity
    3. 2020/06/10 12:07:02.419 22493 22515 Error Unity (Filename: ./Runtime/Export/Debug/Debug.bindings.h Line: 35)
    4. 2020/06/10 12:07:02.419 22493 22515 Error Unity
    5. 2020/06/10 12:07:02.420 22493 22515 Error Unity java.lang.ClassNotFoundException: com.unity3d.services.banners.IUnityBannerListener
    6. 2020/06/10 12:07:02.420 22493 22515 Error Unity
    7. 2020/06/10 12:07:02.420 22493 22515 Error Unity (Filename: ./Runtime/Export/Debug/Debug.bindings.h Line: 35)
    8. 2020/06/10 12:07:02.420 22493 22515 Error Unity
    9.  
    This is indicating that the Ads code is not being properly included when you build your project. If the package manager version isn't working, you could try removing that and using the Asset Store version instead: https://assetstore.unity.com/packages/add-ons/services/unity-monetization-66123

    To be on the safe side, you should also disable Ads from the Unity Editor Services window, as this is not required for the latest versions of the SDK.
     
  8. megalphax

    megalphax

    Joined:
    Jan 10, 2020
    Posts:
    9
    thanks ! now ads work, but the adslistener dont work anymore :/
     
  9. megalphax

    megalphax

    Joined:
    Jan 10, 2020
    Posts:
    9
    oh ! like magic it works now ! thanks ;)
     
    kyle-unity likes this.