loadAd method on AdRequest not allowed

59 views
Skip to first unread message

George Russell

unread,
Mar 5, 2020, 8:22:28 AM3/5/20
to Google Mobile Ads SDK Developers
I successfully implemented an ad in my launcher activity (MainActivity Java.txt).  The same code is being added to a subsequent activity (CheckIn Java.txt0, but I am getting an error on the loadAd method of AdRequest as shown in the attached file (CheckIn Code Error).  It is indicating that "Non Static Method (loadAd com.google.android.gms.ads.AdRequest) cannot be referenced from a static context. 

The code and code location is virtually the same for both activities with the exception of the AdView id name.

Thanks in advance for any assistance. 
MainActivity Java.txt
CheckIn Java.txt
CheckIn Code Error.jpg

Mobile Ads SDK Forum Advisor Prod

unread,
Mar 5, 2020, 3:58:02 PM3/5/20
to george.c...@gmail.com, google-adm...@googlegroups.com
Hello there,

Thanks for reaching out to us. That is happening because you are trying to load a non-static method via a static interface. You need to have a reference to the AdView object and then call loadAd(). Like how we have mentioned in our documentation here

Let us know if you need anything else.

Regards,
Deepika Uragayala
Mobile Ads SDK Team
 

ref:_00D1U1174p._5001UXUBSV:ref
Reply all
Reply to author
Forward
0 new messages