Reputation: 31
I am trying to put AdMob in my android application following the instructions given on android developer website
, but I keep getting the error in my MainActivity.java
AdView.loadAd() error cant resolve the symbol loadAd
Upvotes: 2
Views: 188
Reputation: 20080
By AdView
, I assume you are not referring to the variable.
When you define a new AdView
object, you do so in a way such as the following:
AdView mAdView;
This means that mAdView
is the name of this object and so you call the method with this name. I understand that doesn't sound very clear, but I'll show you what I mean:
// Your new AdView is being cast to the view in your XML, and it is called 'mAdView'
AdView mAdView = (AdView) findViewById(R.id.adView);
// You are creating a new AdRequest here
AdRequest adRequest = new AdRequest.Builder().build();
// Finally, you load the ad (using mAdView as the name, and adRequest as your parameter)
mAdView.loadAd(adRequest);
Make sure your code looks like the above, but to summarise, you need to call your loadAd()
using the name of your AdView
object, for example, mAdView
.
Upvotes: 2