Home » Android » android – Not Showing Firebase Test Native Express ads, getting only live ads, also how to make Native express ads fit the width?

android – Not Showing Firebase Test Native Express ads, getting only live ads, also how to make Native express ads fit the width?

Posted by: admin June 15, 2020 Leave a comment

Questions:

i have set test device sill getting live ads..

mAdView = (NativeExpressAdView) findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder()
    .addTestDevice("722378CE522E161F0EFAD13A658F5161")
    .addTestDevice("048B0A7DC3863535720E0C21AC1C58FD")
    .build();
mAdView.loadAd(adRequest);

and my xml code is:

 <com.google.android.gms.ads.NativeExpressAdView
        android:id="@+id/adView"
        android:layout_width="match_parent"
        android:layout_height="80dp"
        android:layout_above="@+id/l2"
        ads:adSize="360x80"
        ads:adUnitId="@string/native_ads"
/>
How to&Answers:

For getting test native express ads, use following ad unit id-

<string name="native_ad_test_unit_id">ca-app-pub-3940256099942544/6300978111</string>

For getting full width ads, use the FULL_WIDTH constant in the adSize.
For example, your code should be

<com.google.android.gms.ads.NativeExpressAdView
        android:id="@+id/adView"
        android:layout_width="match_parent"
        android:layout_height="80dp"
        android:layout_above="@+id/l2"
        ads:adSize="FULL_WIDTHx80"
        ads:adUnitId="@string/native_ads"
/>

Answer:

Use

ca-app-pub-3940256099942544/6300978111

instead of your own Ad unit id.

Answer:

As described here
https://firebase.google.com/docs/admob/android/native-advanced

it is possible to use

ca-app-pub-3940256099942544/3986624511