title: Admob Crashes app
body: <p>I have an app where I tried to insert admob but after inserting the <code>Admob</code> code my app crashes it says '<strong>Unfortunately, My App has stopped</strong>. Can you please tell me where possibly I am going wrong? Here is the code.</p>
  
  <pre><code>public class MainActivity extends BaseActivity {
  
      /**
       * The intent that will start the list activity
       */
      private Intent activityIntent;
  
      /** Called when the activity is first created. */
      @Override
      public void onCreate(Bundle savedInstanceState) {
  
          super.onCreate(savedInstanceState);
  
          // set the layout
          setContentView(R.layout.activity_main);
          // create the activity that will start the list
          activityIntent = new Intent(mcontext, EntryListActivity.class);
          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);
          // check whether we need to set the default values on the preferences
          if (!preferencesRepository.isDefaultPreferencesSet()) {
              PreferenceManager.setDefaultValues(this, R.xml.preferences, false);
          }
      }
  
      /*
       * (non-Javadoc)
       * 
       * @see android.app.Activity#onResume()
       */
      @Override
      protected void onResume() {
  
          super.onResume();
  
          // initiate Pollfish (see http://www.pollfish.com)
          PollFish.init(this, AppConstants.POLLFISH_API_KEY, Position.TOP_LEFT, 30);
  
          AppUtil.initiateDataCheckService(mcontext);
      }
  
      /**
       * Starts the @EntryListActivity on the emergency tab
       * 
       * @param caller
       */
      public void showEntryList(View caller) {
  
          String category = "";
  
          switch (caller.getId()) {
              case R.id.menu_info:
                  category = mcontext.getString(R.string.CAT_NAME_INFORMATION);
                  break;
              case R.id.menu_transportation:
                  category = mcontext.getString(R.string.CAT_NAME_TRANSPORTATION);
                  break;
              case R.id.menu_embassies:
                  category = mcontext.getString(R.string.CAT_NAME_EMBASSIES);
                  break;
              case R.id.menu_public_services:
                  category = mcontext.getString(R.string.CAT_NAME_PUBLIC_SERVICES);
                  break;
              case R.id.menu_helplines:
                  category = mcontext.getString(R.string.CAT_NAME_HELPLINES);
                  break;
              case R.id.menu_police:
                  category = mcontext.getString(R.string.CAT_NAME_POLICE);
                  break;
              case R.id.menu_healthcare:
                  category = mcontext.getString(R.string.CAT_NAME_HEALTHCARE);
                  break;
              case R.id.menu_emergency:
                  category = mcontext.getString(R.string.CAT_NAME_EMERGENCY);
                  break;
              case R.id.menu_user:
                  category = mcontext.getString(R.string.CAT_NAME_USER_DEFINED);
                  break;
  
          }
  
          // send the tapped category to the @EntryListActivity
          activityIntent.putExtra(EntryListActivity.PARAM_CATEGORY, category);
  
          // start the activity
          startActivity(activityIntent);
  
      }
  
  }
  </code></pre>
  
  <p>here is .xml file</p>
  
  <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:id="@+id/container"
  style="@style/activity_theme"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:gravity="center_horizontal"
  android:orientation="vertical"
  android:padding="0dp" &gt;
  
  &lt;ScrollView
      android:id="@+id/main"
      style="@style/app_container_large_header"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:layout_marginTop="20dp"
      android:orientation="vertical"
      android:paddingBottom="0dp" &gt;
  
      &lt;include
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          layout="@layout/main_grid" /&gt;
  &lt;/ScrollView&gt;
  
  &lt;include layout="@layout/header" /&gt;
  
  &lt;ImageView
      android:id="@+id/shadow"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:layout_below="@+id/main"
      android:layout_gravity="center_horizontal"
      android:contentDescription="@string/Î¤Î§Î¤_EMPTY"
      android:gravity="center_horizontal"
      android:src="@drawable/bottom_shadow" /&gt;
  &lt;LinearLayout
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:orientation="vertical"&gt;
      &lt;com.google.android.gms.ads.AdView
          xmlns:ads="http://schemas.android.com/apk/res-auto"
          android:layout_alignParentTop="true"
          android:id="@+id/adView"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          ads:adUnitId=""
          ads:adSize="BANNER"
          android:background="#ECE5E4"/&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p></p>