user3999945
user3999945

Reputation:

AdMob No Live-Ads appearing

I have made my Application with Android Studio, and now i have a finished app. I added an AdView to my Application, and used the TestAd-UnitId, and i got test ads. On my Emulator and also on my Mobile Phone. That worked, and i had Test Ads running. Then i created an AdMob account, and added my app in there, created a Bannner ad, like i had in my application, and used the adUnitId, from the AdMob page. But when i ran my Application on my phone i got no ads at all. In case it matters: The app isn't on the Play Store.

I read that you have to wait several hours, until you get Live-Ads, but i have been waiting for over 12h, and im Still not getting any ads on my Phone.

If you need it, here is my Code:

My AdView:

<com.google.android.gms.ads.AdView
    android:id="@+id/adView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    app:layout_constraintBottom_toBottomOf="parent"
    ads:adSize="BANNER"
    ads:adUnitId="@string/banner_ad_unit_id"
    android:layout_marginBottom="16dp"
    android:layout_marginLeft="8dp"
    app:layout_constraintLeft_toLeftOf="parent"
    android:layout_marginRight="8dp"
    app:layout_constraintRight_toRightOf="parent" />

My onCreate Method:

MobileAds.initialize(getApplicationContext(), "ca-app-pub-hiddenhiddenhide~hiddenhide");

AdView ad = (AdView) findViewById(R.id.adView);
AdRequest request = new AdRequest.Builder().build();
ad.loadAd(request);

Upvotes: 0

Views: 1947

Answers (1)

vanlooverenkoen
vanlooverenkoen

Reputation: 2301

You need to add this line to the builder.

.addTestDevice(AdRequest.DEVICE_ID_EMULATOR)

so you need to have something like this:

AdRequest request = new AdRequest.Builder()
                        .addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
                        .build();

If you want to use your own mobile phone. you can look for the id in the logcat that needs to be added it will look something like this:

AdRequest request = new AdRequest.Builder()
                    .addTestDevice("here goes your id of your phone")
                    .build();

The reason why you need to do this is because when you are developing you can't see adds because the app is not placed in the playstore. As long as he isn't in the playstore you won't see ads. You can create test-ads with the code is just provided

If you go to production try using this code: (it wil use a testdevice for debugging and developing but it will use real adds for your device as well when in production )

    AdRequest adRequest = new AdRequest.Builder()
            .build();
    if (BuildConfig.DEBUG)
        adRequest = new AdRequest.Builder()
                .addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
                .addTestDevice("your id goes here")
                .build();

Upvotes: 1

Related Questions