Admob 只显示测试广告而不是真实广告

Admob shows only test Ads instead of real Ads

我开发了一款使用 AdMob 展示广告的应用。问题是测试广告在 API 24 及以上显示而不是真实广告,而在 API 23 及以下正常工作。 我不知道是哪个问题,但我可以保证: 1.我没有实现.addTestDevice 2. 我使用我的应用程序 unitID 而不是测试 ID

我附上我的 onCreate 方法:

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_add_edit_text_note);
    //Δημιουργία διαφημίσεων banner

    //Φόρτωση διαφημίσεων banner
    mAdView = findViewById(R.id.adView);
    AdRequest adRequest = new AdRequest.Builder().build();
    mAdView.loadAd(adRequest);

我的布局文件是:

<com.google.android.gms.ads.AdView
    xmlns:ads="http://schemas.android.com/apk/res-auto"
    android:id="@+id/adView"
    android:contentDescription="@string/advertisement"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerHorizontal="true"
    android:layout_alignParentBottom="true"
    ads:adSize="BANNER"
    ads:adUnitId="ca-app-pub-4565************/27********">
</com.google.android.gms.ads.AdView>

我的 build.gradle :

        apply plugin: 'com.android.application'

    android {
        compileSdkVersion 27
        buildToolsVersion '28.0.3'
        defaultConfig {
            applicationId "com.sebastian_pa.sebastian_v2"
            minSdkVersion 16
            targetSdkVersion 27
            versionCode 4
            versionName "1.2"
            testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        }
        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            }
        }
    }

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    implementation 'com.android.support:appcompat-v7:27.0.1'
    implementation 'com.android.support:design:27.0.1'
    testImplementation 'junit:junit:4.12'
    implementation 'com.google.android.gms:play-services-ads:17.0.0'

}

有人知道为什么会这样吗?

有3个地方你需要把你的测试id改成你自己的id。

  1. 在清单文件中
  2. 在你初始化代码
  3. 在您的 xml 文件中

从你的post来看,我看你只做了最后一个

关于第 1 步和第 2 步,请看这里 https://developers.google.com/admob/android/quick-start?hl=en-US#import_the_mobile_ads_sdk

第 3 步请看这里 https://developers.google.com/admob/android/banner?hl=en-US