title: Need to put AdMob ad id in java code? (Android Studio)
body: <p>For example, on one of my app screens where you have a Banner ad, you have the following code in the xml layout:</p>
  
  <pre><code>&lt;com.google.android.gms.ads.AdView
          android:id="@+id/adViewPrincipal"
          android:layout_width="0dp"
          android:layout_height="wrap_content"
          ads:adSize="SMART_BANNER"
          ads:adUnitId="@string/adId" /&gt;
  </code></pre>
  
  <p>And also in java code has the following code:</p>
  
  <pre><code>MobileAds.initialize(this, String.valueOf(R.string.adId));
          adRequest = new AdRequest.Builder().build();
          mAdView.loadAd(adRequest);
  </code></pre>
  
  <p>It seems that everything is working with this test id, but when I take the ID parameter in this java code, leaving: </p>
  
  <pre><code>MobileAds.initialize(this);
  </code></pre>
  
  <p>or</p>
  
  <pre><code>MobileAds.initialize(this, "");
  </code></pre>
  
  <p>The ad keeps running without any errors in the app, so do I just need to set the ad id in XML? Is that in all the tutorials I've seen people putting the ID also in java code. If I leave the parameter with nothing, nothing goes wrong, it's like this parameter is useless, and when I get the ID from the XML code, that crashes app. Can I put the ad id only in XML code then?</p>