I have a massive question to ask as I am really stuck on this and it would be create to get ads on my free application, ok first off I have been following this book
Begi
Create a layout container and put the AdView and the renderView in it:
RelativeLayout layout = new RelativeLayout(this);
AdView adView = new AdView(this, AdSize.BANNER, "a151bf25136cf46");
layout.addView(renderView);
layout.addView(adView);
setContentView(layout);
adView.loadAd(new AdRequest());
EDIT 2020:
Code above is 7 years old and the Google Mobile Ads SDK has changed a lot since then. Here's a minimal code example against the current latest SDK version.
LinearLayout layout = new LinearLayout(this);
layout.setOrientation(LinearLayout.VERTICAL);
AdView adView = new AdView(this);
adView.setAdSize(AdSize.BANNER);
adView.setAdUnitId("ca-app-pub-3940256099942544/6300978111");
adView.loadAd(new AdRequest.Builder().build());
setContentView(layout);