Reputation: 113
I am trying to use AdMob in Android and am following tutorials. I have successfully downloaded, installed and added the Google Play Services library. Nearly everything seems fine.
However Eclipse stubbornly gives a red underline under the "adView.setAdSize" bit. The error message says "The method setAdSize(AdSize) in the type AdView is not applicable for the arguments (AdSize)". I don't see what's wrong, that code is in line with all tutorials and documentation I can find, and why would setAdSize(AdSize) not take in AdSize as an argument? That doesn't make sense to me.
Unfortunately setting the ad size is necessary for the code to run so I can't just remove that bit. Relevant code is below. Thanks to anyone that can help.
...
import com.google.ads.AdSize;
import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdView;
public class MainActivity extends ActionBarActivity{
private AdView adView;
@Override
protected void onCreate(Bundle savedInstanceState) {
...
// Create the adView.
adView = new AdView(this);
adView.setAdSize(AdSize.SMART_BANNER);
adView.setAdUnitId("ID REMOVED FOR PRIVACY REASONS");
...
}
...
}
Upvotes: 1
Views: 1617
Reputation: 1136
Change:
import com.google.ads.AdSize;
For:
import com.google.android.gms.ads.AdSize;
Upvotes: 7