我已经用 Android Studio 制作了我的应用程序,现在我有了一个完成的应用程序。我在我的应用程序中添加了一个 AdView,并使用了 TestAd-UnitId,我得到了测试广告。在我的模拟器和手机上。那行得通,我运行了测试广告。然后我创建了一个 AdMob 帐户,并在其中添加了我的应用程序,创建了一个 Bannner 广告,就像我在我的应用程序中一样,并使用了来自 AdMob 页面的 adUnitId。但是当我在手机上运行我的应用程序时,我根本没有收到任何广告。以防万一:该应用不在 Play 商店中。
我读到您必须等待几个小时才能获得实时广告,但我已经等待了超过 12 小时,我的手机上仍然没有收到任何广告。
如果你需要它,这是我的代码:
我的广告视图:
<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" />
我的 onCreate 方法:
MobileAds.initialize(getApplicationContext(), "ca-app-pub-hiddenhiddenhide~hiddenhide");
AdView ad = (AdView) findViewById(R.id.adView);
AdRequest request = new AdRequest.Builder().build();
ad.loadAd(request);