RevMob in Unity

  • JeffGordonRamsay
    Likes 0

    Problem Description

    I’m following the tutorial on RevMob for implementing banner ads in my mobile game, and I keep getting an error that says "NullReferenceException: Object reference not set to an instance of an object RevMobID.Start ()".  I'm still a novice programmer, so this could be a simple issue.  Here’s what I have:

    public class RevMobID : MonoBehaviour 
    {
    
    private RevMobBanner banner;
    
    private static readonly Dictionary<String, String> REVMOB_APP_IDS = new Dictionary<String, String> ()
     {
          {"IOS", "(my ad ID here)"}
     };
     private RevMob revmob;
    
     void Awake()
     {
          Debug.Log ("RevMob start);
          revmob = RevMob.Start (REVMOB_APP_IDS, "Banner Ad");
     }
    
     void Start()
     {
          #if UNITY_IPHONE
               banner = revmob.CreateBanner(0, 0, Screen.width, Screen.height/10, null, null); // the console pinpoints the error here
               banner.Show();
          #endif
     }
    
  • GAZ99 admin
    Likes 1

    Hi, Just at looking at the code you’ve posted, you are missing a closing quote(“) on the following:

     

     Debug.Log ("RevMob start);

    should be

     Debug.Log ("RevMob start);

     

    let me know if this fixes the problem for you.

     

    Gaz

  • JeffGordonRamsay
    Likes 0

    Ah I’m sorry, I’m on my PC and rewrote it from my Mac; yes, I have the closing quote in my code.  The error points to the line “banner = revmob.CreateBanner(0, 0, Screen.width, Screen.heigh/10, null, null);  I’ve tried including “RevMobBanner” in front of this line, but the same error pops up.

Login to reply