0

I was working with adMob, on my emulator with a test ads:adUnitId

public class BalloonDefense extends Activity {

Surface view;
WakeLock WL;

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    //full screen
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

    //ad--------------------------------------------------------------------------CHANGE ME 1 (change advert unit id)
    AdView ad = new AdView(this);
    ad.setAdUnitId("ca-app-pub-4270508386283746/3070375087");
    ad.setAdSize(AdSize.BANNER);
    RelativeLayout layout = new RelativeLayout(this);

    //layout
    view = new Surface(this, this); 

    LayoutParams params1 = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    params1.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
    params1.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
    ad.setLayoutParams(params1);

    layout.addView(view);
    layout.addView(ad);
    setContentView(layout);

    //ad`enter code here`
     AdRequest adRequest = new AdRequest.Builder()
        .addTestDevice(AdRequest.DEVICE_ID_EMULATOR)      
        .build();
     **ad.loadAd(adRequest);**`

If it add ad.loadAd(adRequest);, the application is closes? Why? Thanks!

MrEngineer13
  • 38,642
  • 13
  • 74
  • 93

1 Answers1

0

Here is what the Google play services documentation says for "loadAd()":

AdView adView = (AdView)this.findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder()
    .addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
    .addTestDevice("TEST_DEVICE_ID")
    .build();
adView.loadAd(adRequest);

Maybe try adding the ".addTestDevice("TEST_DEVICE_ID")" and see if that works. Also, here is the link to the documentation: https://developers.google.com/mobile-ads-sdk/docs/admob/android/play-migration

Hope that helps :)

Scumble373
  • 227
  • 3
  • 7