title: Can't load admob native ads
body: <p>When i try to load a native ad with a template this is the XML code i use:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:ads="http://schemas.android.com/apk/res-auto"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:orientation="vertical"
      android:background="#ededed"&gt;
  
       &lt;com.google.android.gms.ads.NativeExpressAdView
          android:id="@+id/adView"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:layout_centerHorizontal="true"
          android:layout_alignParentBottom="true"
          ads:adSize="320x150"
          ads:adUnitId="@string/native_ad_exit_app"&gt;
      &lt;/com.google.android.gms.ads.NativeExpressAdView&gt;
  
     &lt;TextView
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
         android:textSize="@dimen/title_bold"
         android:text="@string/sure_wanna_exit"
         android:textColor="@android:color/white"
         android:padding="@dimen/half_activity_horizontal_margin"
         android:gravity="center"
         android:background="@color/standard_android_blue"/&gt;
  
     &lt;LinearLayout
         android:layout_width="match_parent"
         android:layout_height="@dimen/standard_button_size"&gt;
  
         &lt;Button android:id="@+id/btnStayApp"
             android:layout_width="0dp"
             android:layout_weight="1"
             android:layout_height="match_parent"
             android:background="@android:color/transparent"
             android:text="@string/stay"
             android:textColor="#999999"/&gt;
  
         &lt;View
             android:layout_width="2dp"
             android:layout_height="match_parent"
             android:background="@color/standard_android_blue"/&gt;
  
         &lt;Button android:id="@+id/btnExitApp"
             android:layout_width="0dp"
             android:layout_weight="1"
             android:layout_height="match_parent"
             android:background="@android:color/transparent"
             android:text="@string/exit"
             android:textColor="@color/standard_android_blue"/&gt;
  
     &lt;/LinearLayout&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>And this is the java code:</p>
  
  <pre><code>public class NativeAdDialog extends DialogFragment {
  
      /**********************/
      /** Create the dialog**/
      /**********************/
  
      @Override
      public Dialog onCreateDialog(Bundle savedInstanceState) {
  
          final View v = getActivity().getLayoutInflater().inflate(R.layout.native_ad_container, null);
  
          /********************/
          /** Exit app button */
          /********************/
  
          Button exitAppButton = (Button)v.findViewById(R.id.btnExitApp);
          exitAppButton.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  getActivity().finish();
              }
          });
  
          /********************/
          /** Stay app button */
          /********************/
  
          Button stayAppButton = (Button)v.findViewById(R.id.btnStayApp);
          stayAppButton.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  dismiss();
              }
          });
  
          /***********/
          /** The ad */
          /***********/
  
          NativeExpressAdView adView = (NativeExpressAdView) v.findViewById(R.id.adView);
          adView.loadAd(new AdRequest.Builder().build());
  
          return new AlertDialog.Builder(getActivity()).setView(v).create();
      }
  
  }
  </code></pre>
  
  <p>After it failed i tried to set a custom native ad like in this project:
  <a href="https://github.com/googleads/googleads-mobile-android-examples/tree/master/admob/NativeExample" rel="nofollow">https://github.com/googleads/googleads-mobile-android-examples/tree/master/admob/NativeExample</a></p>
  
  <p>So i added the next code to my java file:</p>
  
  <pre><code>/**
       * Populates a {@link NativeAppInstallAdView} object with data from a given
       * {@link NativeAppInstallAd}.
       *
       * @param nativeAppInstallAd the object containing the ad's assets
       * @param adView             the view to be populated
       */
      private void populateAppInstallAdView(NativeAppInstallAd nativeAppInstallAd,
                                            NativeAppInstallAdView adView) {
          adView.setHeadlineView(adView.findViewById(R.id.appinstall_headline));
          adView.setImageView(adView.findViewById(R.id.appinstall_image));
          adView.setBodyView(adView.findViewById(R.id.appinstall_body));
          adView.setCallToActionView(adView.findViewById(R.id.appinstall_call_to_action));
          adView.setIconView(adView.findViewById(R.id.appinstall_app_icon));
          adView.setPriceView(adView.findViewById(R.id.appinstall_price));
          adView.setStarRatingView(adView.findViewById(R.id.appinstall_stars));
          adView.setStoreView(adView.findViewById(R.id.appinstall_store));
  
          // Some assets are guaranteed to be in every NativeAppInstallAd.
          ((TextView) adView.getHeadlineView()).setText(nativeAppInstallAd.getHeadline());
          ((TextView) adView.getBodyView()).setText(nativeAppInstallAd.getBody());
          ((Button) adView.getCallToActionView()).setText(nativeAppInstallAd.getCallToAction());
          ((ImageView) adView.getIconView()).setImageDrawable(nativeAppInstallAd.getIcon()
                  .getDrawable());
  
          List&lt;NativeAd.Image&gt; images = nativeAppInstallAd.getImages();
  
          if (images.size() &gt; 0) {
              ((ImageView) adView.getImageView()).setImageDrawable(images.get(0).getDrawable());
          }
  
          // Some aren't guaranteed, however, and should be checked.
          if (nativeAppInstallAd.getPrice() == null) {
              adView.getPriceView().setVisibility(View.INVISIBLE);
          } else {
              adView.getPriceView().setVisibility(View.VISIBLE);
              ((TextView) adView.getPriceView()).setText(nativeAppInstallAd.getPrice());
          }
  
          if (nativeAppInstallAd.getStore() == null) {
              adView.getStoreView().setVisibility(View.INVISIBLE);
          } else {
              adView.getStoreView().setVisibility(View.VISIBLE);
              ((TextView) adView.getStoreView()).setText(nativeAppInstallAd.getStore());
          }
  
          if (nativeAppInstallAd.getStarRating() == null) {
              adView.getStarRatingView().setVisibility(View.INVISIBLE);
          } else {
              ((RatingBar) adView.getStarRatingView())
                      .setRating(nativeAppInstallAd.getStarRating().floatValue());
              adView.getStarRatingView().setVisibility(View.VISIBLE);
          }
  
          // Assign native ad object to the native view.
          adView.setNativeAd(nativeAppInstallAd);
      }
  
      /**
       * Populates a {@link NativeContentAdView} object with data from a given
       * {@link NativeContentAd}.
       */
      private void populateContentAdView(NativeContentAd nativeContentAd,
                                         NativeContentAdView adView) {
          adView.setHeadlineView(adView.findViewById(R.id.contentad_headline));
          adView.setImageView(adView.findViewById(R.id.contentad_image));
          adView.setBodyView(adView.findViewById(R.id.contentad_body));
          adView.setCallToActionView(adView.findViewById(R.id.contentad_call_to_action));
          adView.setLogoView(adView.findViewById(R.id.contentad_logo));
          adView.setAdvertiserView(adView.findViewById(R.id.contentad_advertiser));
  
          // Some assets are guaranteed to be in every NativeContentAd.
          ((TextView) adView.getHeadlineView()).setText(nativeContentAd.getHeadline());
          ((TextView) adView.getBodyView()).setText(nativeContentAd.getBody());
          ((TextView) adView.getCallToActionView()).setText(nativeContentAd.getCallToAction());
          ((TextView) adView.getAdvertiserView()).setText(nativeContentAd.getAdvertiser());
  
          List&lt;NativeAd.Image&gt; images = nativeContentAd.getImages();
  
          if (images.size() &gt; 0) {
              ((ImageView) adView.getImageView()).setImageDrawable(images.get(0).getDrawable());
          }
  
          // Some aren't guaranteed, however, and should be checked.
          NativeAd.Image logoImage = nativeContentAd.getLogo();
  
          if (logoImage == null) {
              adView.getLogoView().setVisibility(View.INVISIBLE);
          } else {
              ((ImageView) adView.getLogoView()).setImageDrawable(logoImage.getDrawable());
              adView.getLogoView().setVisibility(View.VISIBLE);
          }
  
          // Assign native ad object to the native view.
          adView.setNativeAd(nativeContentAd);
      }
  
      /**
       * Creates a request for a new native ad based on the boolean parameters and calls the
       * corresponding "populate" method when one is successfully returned.
       */
      private void refreshAd() {
  
          AdLoader adLoader = new AdLoader.Builder(getActivity(), getResources().getString(R.string.native_ad_exit_app))
                  .forAppInstallAd(new NativeAppInstallAd.OnAppInstallAdLoadedListener() {
                      @Override
                      public void onAppInstallAdLoaded(NativeAppInstallAd appInstallAd) {
                          // Show the app install ad.
                          NativeAppInstallAdView adView = (NativeAppInstallAdView) getActivity().getLayoutInflater()
                                  .inflate(R.layout.ad_app_install, null);
                          populateAppInstallAdView(appInstallAd, adView);
                          adPlaceholder.removeAllViews();
                          adPlaceholder.addView(adView);
                      }
                  })
                  .forContentAd(new NativeContentAd.OnContentAdLoadedListener() {
                      @Override
                      public void onContentAdLoaded(NativeContentAd contentAd) {
                          // Show the content ad.
                          NativeContentAdView adView = (NativeContentAdView) getActivity().getLayoutInflater()
                                  .inflate(R.layout.ad_content, null);
                          populateContentAdView(contentAd, adView);
                          adPlaceholder.removeAllViews();
                          adPlaceholder.addView(adView);
                      }
                  })
                  .withAdListener(new AdListener() {
                      @Override
                      public void onAdFailedToLoad(int errorCode) {
                          // Handle the failure by logging, altering the UI, etc.
                      }
  
                  })
                  .withNativeAdOptions(new NativeAdOptions.Builder()
                          // Methods in the NativeAdOptions.Builder class can be
                          // used here to specify individual options settings.
                          .build())
                  .build();
  
          adLoader.loadAd(new AdRequest.Builder().build());
  
  }
  </code></pre>
  
  <p>I call refreshAd on onCreate method but adLoader.isLoading() always return false. </p>
  
  <p>What am i doing wrong?</p>