web-dev-qa-db-ja.com

admobバナーのライブ広告は表示されていませんがテスト表示

MainActivityコード:

MobileAds.initialize(this, getResources().getString(R.string.app_id));
mAdView = findViewById(R.id.adView);
            mAdView.setVisibility(View.VISIBLE);
            AdRequest adRequest = new AdRequest.Builder().build();
            mAdView.loadAd(adRequest); 

main_activity.xmlファイル

 <com.google.Android.gms.ads.AdView xmlns:ads="http://schemas.Android.com/apk/res-auto"
        Android:id="@+id/adView"
        Android:layout_width="match_parent"
        Android:layout_height="wrap_content"
        Android:layout_alignParentBottom="true"
        ads:adSize="BANNER"
        ads:adUnitId="ca-app-pub-7758424290736454/1358492948" />

テストIDを追加すると、広告が表示されます。

ca-app-pub-3940256099942544/6300978111

以下のエラーログが表示されます

DynamitePackage: Instantiating com.google.Android.gms.ads.ChimeraMobileAdsSettingManagerCreatorImpl
    01-29 16:19:28.141 6523-6523/com.recreation.cryptocurrencyrate I/art:     at void com.google.Android.gms.ads.MobileAds.initialize(Android.content.Context, Java.lang.String, com.google.Android.gms.ads.MobileAds$Settings) ((null):-1)
    01-29 16:19:28.141 6523-6523/com.recreation.cryptocurrencyrate I/art:     at void com.google.Android.gms.ads.MobileAds.initialize(Android.content.Context, Java.lang.String) ((null):-1)
    01-29 16:19:28.142 6523-6523/com.recreation.cryptocurrencyrate I/art:     at void com.google.Android.gms.ads.MobileAds.initialize(Android.content.Context, Java.lang.String, com.google.Android.gms.ads.MobileAds$Settings) ((null):-1)
    01-29 16:19:28.142 6523-6523/com.recreation.cryptocurrencyrate I/art:     at void com.google.Android.gms.ads.MobileAds.initialize(Android.content.Context, Java.lang.String) ((null):-1)
    01-29 16:19:30.961 6523-6523/com.recreation.cryptocurrencyrate I/Ads: Starting ad request.
    01-29 16:19:30.961 6523-6523/com.recreation.cryptocurrencyrate I/Ads: This request is sent from a test device.
    01-29 16:19:30.972 6523-6523/com.recreation.cryptocurrencyrate W/Ads: Not retrying to fetch app settings
    01-29 16:19:33.499 6523-6540/com.recreation.cryptocurrencyrate W/Ads: There was a problem getting an ad response. ErrorCode: 0
    01-29 16:19:33.506 6523-6523/com.recreation.cryptocurrencyrate W/Ads: Failed to load ad: 0

AdmobアプリユニットIDダッシュボード。

admob account dasboard

5
Abdul Qadir

Adunit IDが新しく作成されたため、Adunitを確認してアプリに広告を表示するには時間がかかります。問題は、作成したアドユニットIDにあります。 AdUnitIDを使用してアプリにテスト広告を表示します。

以下の手順に従ってください:-

ライブ広告ユニットIDを作成するには

にサインイン

https://apps.admob.com

左側のメニューで[アプリの追加]をクリックし、アプリをGooglePlayまたはAppStoreで公開したかどうかを選択します。公開していない場合は、アプリ情報を入力します。広告ユニットの作成テスト広告ユニットを新しい広告ユニットに置き換えます。アプリがPlayストアに公開されると、ADが表示されます。

1

以下のコードをandroidmanifest.xmlに追加するかどうかを確認してください。

<uses-permission Android:name="Android.permission.INTERNET" />
<uses-permission Android:name="Android.permission.ACCESS_NETWORK_STATE" />

そして

 <meta-data
        Android:name="com.google.Android.gms.version"
        Android:value="@integer/google_play_services_version" />

すでに追加したようです

compile 'com.google.Android.gms:play-services-ads:8.4.0'

build.gradleに

すべて完了したら、広告は機能するはずです。

0
ust