user1581390
user1581390

Reputation: 1998

Admob Displays Ads in Emulator but Not on Phone

I am able to view test ads on the emulator but when I install the same app (release version) on a phone with regular / test ads, the banner doesn't show.

<com.google.android.gms.ads.AdView 
    xmlns:ads="http://schemas.android.com/apk/res-auto"
    android:id="@+id/adView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_centerHorizontal="true"
    android:layout_marginEnd="8dp"
    android:layout_marginStart="8dp"
    android:layout_marginTop="8dp"
    ads:adSize="BANNER"
    ads:adUnitId="ca-app-pub-2011402599521768/7649302302"
    ads:layout_constraintBottom_toBottomOf="parent"
    ads:layout_constraintEnd_toEndOf="parent"
    ads:layout_constraintStart_toStartOf="parent"
    ads:layout_constraintTop_toBottomOf="@+id/button_feedback"
    ads:layout_constraintVertical_bias="1.0">
</com.google.android.gms.ads.AdView>

Ad loading code:

// Sample AdMob app ID: ca-app-pub-3940256099942544~3347511713
MobileAds.initialize(this, "ca-app-pub-2011402599521768~7160726450");

AdView adView = (AdView)findViewById(R.id.adView);

// Test ads:
AdRequest adRequest = new AdRequest.Builder()
            .addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
            .build();

//AdRequest adRequest = new AdRequest.Builder().build();

adView.loadAd(adRequest);

Upvotes: 0

Views: 466

Answers (2)

user1581390
user1581390

Reputation: 1998

The problem was solved by logging into Admob and configuring payments, then some minutes later the ads began to be served.

Upvotes: 0

Hatchi Roku
Hatchi Roku

Reputation: 1004

Your real device might be not registered as a test device, try to read this document about test requests: https://developers.google.com/admob/android/test-ads#enable_test_devices You can replace it with a regular request to know if adding a test device is the problem.

Upvotes: 1

Related Questions