title: Adding Banner ad Admob in Android studio
body: <p>Please help me. This code isn't working when I add admob to my programm. May be I'm using it the wrong way. Please suggest me editing of the code with banner ad admob. Where should I add admob code?
  There is no error in Debug but app is not running Cannot load app. Thank you.</p>
  <pre><code>    @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_nvg_drawer);
          Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
          setSupportActionBar(toolbar);
  
          DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
          ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
                  this, drawer, toolbar, R.string.navigation_drawer_open,    R.string.navigation_drawer_close);
          drawer.setDrawerListener(toggle);
          toggle.syncState();
  
          NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
          navigationView.setNavigationItemSelectedListener(this);
  
          mYoutubeDataApi = new YouTube.Builder(mTransport, mJsonFactory, null)
                  .setApplicationName(getResources().getString(R.string.app_name))
                  .build();
  
          youtubePlaylist = getString(R.string.playlist_1);
          token = null;
          listVideoInfo = null;
          listViewVideo = (ListView) findViewById(R.id.list_view_video);
          listViewVideo.setOnItemClickListener(onItemClickListener);
  
          setTitle(getIntent().getStringExtra(&quot;USER_NAME&quot;));
          loadPlayList();
  
          mAdView = (AdView) findViewById(R.id.ad_view);
          AdRequest adRequest = new AdRequest.Builder()
                  .addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
                  .addTestDevice(&quot;55DBCB068B472972E7ABC20D047D27E4&quot;)// Add your real device id here
                  .build();
          // Start loading the ad in the background.
          mAdView.loadAd(adRequest);
      }
  
      /**
       * Called when leaving the activity
       */
      @Override
      public void onPause() {
          if (mAdView != null) {
              mAdView.pause();
          }
          super.onPause();
      }
  
      /**
       * Called when returning to the activity
       */
      @Override
      public void onResume() {
          super.onResume();
          if (mAdView != null) {
              mAdView.resume();
          }
      }
  
      /**
       * Called before the activity is destroyed
       */
      @Override
      public void onDestroy() {
          if (mAdView != null) {
              mAdView.destroy();
          }
          super.onDestroy();
      }
      
  
      private void loadPlayList(){
          new GetPlaylistAsyncTask(mYoutubeDataApi, getApplicationContext()) {
              int numbersPage;
              @Override
              protected void onProgressUpdate(final Integer... values) {
                  super.onProgressUpdate(values);
                  numbersPage = values[0] / 10;
              }
  
              @Override
              public void onPostExecute(Pair&lt;String, List&lt;VideoInfo&gt;&gt; result) {
                  token=result.first;
                  if(listVideoInfo ==null) {
                      listVideoInfo = result.second;
                      adapterVideo=new AdapterVideo(getApplicationContext(), listVideoInfo);
                      listViewVideo.setAdapter(adapterVideo);
                      listViewVideo.setOnScrollListener(new InfiniteScrollListener(1,numbersPage) {
                          @Override
                          public void onReloadItems(int pageToRequest) {
                              loadPlayList();
                          }
  
                          @Override
                          public void onReloadFinished() {
  
                          }
                      });
                  }
                  else {
                      listVideoInfo.addAll(result.second);
                      adapterVideo.notifyDataSetChanged();
                  }
              }
          }.execute(youtubePlaylist, token);
      }
  
      AdapterView.OnItemClickListener onItemClickListener = new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView&lt;?&gt; parent, View view, int position,  long id) {
              Intent intent = new Intent(getApplicationContext(),      YtbActivity.class);
              intent.putExtra(&quot;VIDEO_ID&quot;, listVideoInfo.get(position).getId());
              startActivity(intent);
          }
      };
  
      @Override
      public void onBackPressed() {
          DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
          if (drawer.isDrawerOpen(GravityCompat.START)) {
              drawer.closeDrawer(GravityCompat.START);
          } else {
              super.onBackPressed();
          }
  
      }
  
  
      @Override
      public boolean onOptionsItemSelected(MenuItem item) {
          // Handle action bar item clicks here. The action bar will
          // automatically handle clicks on the Home/Up button, so long
          // as you specify a parent activity in AndroidManifest.xml.
          int id = item.getItemId();
  
          //noinspection SimplifiableIfStatement
          if (id == R.id.action_settings) {
              return true;
          }
  
          return super.onOptionsItemSelected(item);
      }
  
      @SuppressWarnings(&quot;StatementWithEmptyBody&quot;)
      @Override
      public boolean onNavigationItemSelected(MenuItem item) {
          int id = item.getItemId();
  
          if (id == R.id.pl_list1) {
              youtubePlaylist = getString(R.string.playlist_1);
              listVideoInfo =null;
              token=null;
              loadPlayList();
          } else if (id == R.id.pl_list2) {
              youtubePlaylist = getString(R.string.playlist_2);
              listVideoInfo =null;
              token=null;
              loadPlayList();
          } else if (id == R.id.pl_list3) {
              youtubePlaylist = getString(R.string.playlist_3);
              listVideoInfo =null;
              token=null;
              loadPlayList();
          }
  
          DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
          drawer.closeDrawer(GravityCompat.START);
          return true;
      }
     }
  </code></pre>
  <p>Activity_main.xml</p>
  <pre><code> &lt;android.support.design.widget.CoordinatorLayout
          xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
          xmlns:ads=&quot;http://schemas.android.com/apk/res-auto&quot;
          xmlns:app=&quot;http://schemas.android.com/apk/res-auto&quot;
          xmlns:tools=&quot;http://schemas.android.com/tools&quot;
          android:layout_width=&quot;match_parent&quot;
          android:layout_height=&quot;match_parent&quot;
          android:fitsSystemWindows=&quot;true&quot;
          tools:context=&quot;.MainActivity&quot;&gt;
      
          &lt;RelativeLayout
              android:id=&quot;@+id/main_content&quot;
              android:layout_width=&quot;match_parent&quot;
              android:layout_height=&quot;match_parent&quot;&gt;
      
              &lt;android.support.design.widget.CoordinatorLayout
                  android:layout_width=&quot;match_parent&quot;
                  android:layout_height=&quot;match_parent&quot;
                  android:layout_above=&quot;@+id/ad_view&quot;&gt;
      
                  &lt;android.support.design.widget.AppBarLayout
                      android:layout_width=&quot;match_parent&quot;
                      android:layout_height=&quot;wrap_content&quot;
                      android:theme=&quot;@style/AppTheme.AppBarOverlay&quot;&gt;
      
                      &lt;android.support.v7.widget.Toolbar
                          android:id=&quot;@+id/toolbar&quot;
                          android:layout_width=&quot;match_parent&quot;
                          android:layout_height=&quot;?attr/actionBarSize&quot;
                          android:background=&quot;?attr/colorPrimary&quot;
                          app:layout_scrollFlags=&quot;scroll|enterAlways&quot;
                          app:popupTheme=&quot;@style/AppTheme.PopupOverlay&quot; /&gt;
      
      
                  &lt;/android.support.design.widget.AppBarLayout&gt;
      
                  &lt;ListView
                      android:layout_width=&quot;match_parent&quot;
                      android:layout_height=&quot;match_parent&quot;
                      android:id=&quot;@+id/list_view_video&quot;&gt;
      
                  &lt;/ListView&gt;
      
              &lt;/android.support.design.widget.CoordinatorLayout&gt;
      
              &lt;com.google.android.gms.ads.AdView
                  android:id=&quot;@+id/ad_view&quot;
                  android:layout_width=&quot;wrap_content&quot;
                  android:layout_height=&quot;wrap_content&quot;
                  android:layout_centerHorizontal=&quot;true&quot;
                  android:layout_alignParentBottom=&quot;true&quot;
                  ads:adSize=&quot;BANNER&quot;
                  ads:adUnitId=&quot;ca-app-pub-3940256099942544/6300978111&quot;&gt;
              &lt;/com.google.android.gms.ads.AdView&gt;
      
          &lt;/RelativeLayout&gt;
          &lt;/android.support.design.widget.CoordinatorLayout&gt;
  </code></pre>