title: Android NativeAppInstallAdView never shows the ad
body: <p>I have a problem with showing native app install ad view in one of my activities. As Google shows the implementation of native ads on: 
  <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> I have integrated the code to my project. Here is my gradle file:</p>
  
  <pre><code>apply plugin: 'com.android.application'
  
  android {
      compileSdkVersion 23
      buildToolsVersion "23.0.3"
  
      defaultConfig {
          applicationId "com.somepack.tests"
          minSdkVersion 15
          targetSdkVersion 23
          versionCode 1
          versionName "1.0"
      }
      buildTypes {
          release {
              minifyEnabled false
              proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
          }
      }
  }
  
  dependencies {
      compile fileTree(dir: 'libs', include: ['*.jar'])
      testCompile 'junit:junit:4.12'
  
      compile 'com.android.support:appcompat-v7:23.4.0'
      compile 'com.android.support:design:23.4.0'
      compile 'com.android.support:recyclerview-v7:23.4.0'
      compile 'com.android.support:cardview-v7:23.4.0'
      compile 'com.google.android.gms:play-services-ads:9.2.0'
      compile 'com.google.firebase:firebase-ads:9.0.0'
  }
  
  apply plugin: 'com.google.gms.google-services'
  </code></pre>
  
  <p>And I have also added same code to my root gradle file:</p>
  
  <pre><code>// Top-level build file where you can add configuration options common to all sub-projects/modules.
  
  buildscript {
      repositories {
          mavenLocal()
          jcenter()
      }
      dependencies {
          classpath 'com.android.tools.build:gradle:2.1.2'
          classpath 'com.google.gms:google-services:3.0.0'
  
          // NOTE: Do not place your application dependencies here; they belong
          // in the individual module build.gradle files
      }
  }
  
  allprojects {
      repositories {
          mavenLocal()
          jcenter()
      }
  }
  
  task clean(type: Delete) {
      delete rootProject.buildDir
  }
  </code></pre>
  
  <p>I have tried to run the app with Google's app id and unit id, and everything seems to be working. When I change app id and unit id to my values, it just keeps saying 'Failed to load native ad' with the error code 0. </p>
  
  <p>And here is my activity:</p>
  
  <pre><code>import android.os.Bundle;
  import android.support.v7.app.AppCompatActivity;
  import android.view.View;
  import android.widget.Button;
  import android.widget.FrameLayout;
  import android.widget.ImageView;
  import android.widget.RatingBar;
  import android.widget.TextView;
  import android.widget.Toast;
  
  import com.google.android.gms.ads.AdListener;
  import com.google.android.gms.ads.AdLoader;
  import com.google.android.gms.ads.AdRequest;
  import com.google.android.gms.ads.MobileAds;
  import com.google.android.gms.ads.formats.NativeAd;
  import com.google.android.gms.ads.formats.NativeAppInstallAd;
  import com.google.android.gms.ads.formats.NativeAppInstallAdView;
  
  import java.util.List;
  
  public class AdActivity extends AppCompatActivity {
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_ad);
  
          String ADMOB_APP_ID = getString(R.string.admob_app_id);
          // Initialize the Mobile Ads SDK.
          MobileAds.initialize(this, ADMOB_APP_ID);
          refreshAd();
      }
  
      private AdRequest.Builder getBuilder() {
          AdRequest.Builder builder = new AdRequest.Builder();
          if (BuildConfig.DEBUG) {
              builder.addTestDevice("BDFA4B1F1E11FDA72D43368841CF0E04");
          }
          return builder;
      }
  
      private void refreshAd() {
          AdLoader.Builder builder = new AdLoader.Builder(this, getString(R.string.admob_unit_id));
          builder.forAppInstallAd(new NativeAppInstallAd.OnAppInstallAdLoadedListener() {
              @Override
              public void onAppInstallAdLoaded(NativeAppInstallAd ad) {
                  FrameLayout frameLayout =
                          (FrameLayout) findViewById(R.id.fl_adplaceholder);
                  NativeAppInstallAdView adView = (NativeAppInstallAdView) getLayoutInflater()
                          .inflate(R.layout.ad_app_install, null);
                  populateAppInstallAdView(ad, adView);
                  frameLayout.removeAllViews();
                  frameLayout.addView(adView);
              }
          });
  
          AdLoader adLoader = builder.withAdListener(new AdListener() {
              @Override
              public void onAdFailedToLoad(int errorCode) {
                  Toast.makeText(AdActivity.this, "Failed to load native ad: "
                          + errorCode, Toast.LENGTH_SHORT).show();
              }
          }).build();
  
          adLoader.loadAd(getBuilder().build());
      }
  
      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);
      }
  }
  </code></pre>
  
  <p>I thought it doesn't show the ad because my apk is debug and tried with release too. But no chance. Am I missing a setting on Admob panel or any code that I need to implement? I am greatly appriciated for any help.</p>
  
  <p>P.S: The code I wrote above is just a trial, I have the same code in my real app, which is on Play Store, but could not succeed.</p>