广告未显示在AdView

时间:2018-04-16 14:23:24

标签: android admob google-admob

我是新手将AdMob与Android集成。我遇到了广告未在AdView中显示的问题。我已将firebase链接到我的AdMob帐户。根据我的发现,这应该显示广告。但我不知道为什么会发生这种情况

我的活动,

MobileAds.initialize(MainActivity.this, "my-id");

AdView adView = (AdView) findViewById(R.id.adview);
AdRequest adRequest = new AdRequest.Builder().build();
adView.loadAd(adRequest);

布局,

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

<android.support.v7.widget.RecyclerView
    android:id="@+id/main_recycler_view"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="1"
    android:background="@color/colorGrey"
    android:scrollbars="vertical" />

<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_centerHorizontal="true"
    android:layout_alignParentBottom="true"
    ads:adSize="BANNER"
    ads:adUnitId="@string/banner_ad_unit_id">
</com.google.android.gms.ads.AdView>

我的日志,

04-16 19:38:26.146 10178-10268/com.example.my.app W/zygote64: Skipping duplicate class check due to unrecognized classloader
04-16 19:38:26.150 10178-10264/com.example.my.app W/VideoCapabilities: Unrecognized profile 2130706433 for video/avc
04-16 19:38:26.150 10178-10264/com.example.my.app W/VideoCapabilities: Unrecognized profile 2130706434 for video/avc
04-16 19:38:26.151 10178-10178/com.example.my.app I/Ads: Starting ad request.
04-16 19:38:26.154 10178-10178/com.example.my.app I/Ads: Use AdRequest.Builder.addTestDevice("FFD5F3261542E02E3D30EE7D21F08733") to get test ads on this device.
04-16 19:38:26.157 10178-10178/com.example.my.app W/Ads: Not retrying to fetch app settings
04-16 19:38:26.177 10178-10264/com.example.my.app W/VideoCapabilities: Unrecognized profile 2130706433 for video/avc
04-16 19:38:26.177 10178-10264/com.example.my.app W/VideoCapabilities: Unrecognized profile 2130706434 for video/avc
04-16 19:38:26.183 10178-10264/com.example.my.app W/VideoCapabilities: Unrecognized profile 2130706433 for video/avc
04-16 19:38:26.183 10178-10264/com.example.my.app W/VideoCapabilities: Unrecognized profile 2130706434 for video/avc
04-16 19:38:26.196 10178-10264/com.example.my.app W/VideoCapabilities: Unrecognized profile/level 0/3 for video/mpeg2
04-16 19:38:26.201 10178-10264/com.example.my.app W/VideoCapabilities: Unrecognized profile/level 0/3 for video/mpeg2
04-16 19:38:26.211 10178-10279/com.example.my.app W/Ads: Invoke Firebase method getInstance error.
04-16 19:38:26.211 10178-10279/com.example.my.app W/Ads: The Google Mobile Ads SDK will not integrate with Firebase. Admob/Firebase integration requires the latest Firebase SDK jar, but Firebase SDK is either missing or out of date
04-16 19:38:26.213 10178-10264/com.example.my.app W/VideoCapabilities: Unsupported mime video/x-ms-wmv
04-16 19:38:26.216 10178-10264/com.example.my.app W/VideoCapabilities: Unsupported mime video/x-ms-wmv
04-16 19:38:26.218 10178-10264/com.example.my.app W/VideoCapabilities: Unsupported mime video/divx
04-16 19:38:26.221 10178-10264/com.example.my.app W/VideoCapabilities: Unsupported mime video/divx311
04-16 19:38:26.226 10178-10264/com.example.my.app W/VideoCapabilities: Unsupported mime video/divx4
04-16 19:38:26.227 10178-10178/com.example.my.app D/AppTracker: App Event: start
04-16 19:38:26.236 10178-10183/com.example.my.app I/zygote64: Do partial code cache collection, code=61KB, data=43KB
04-16 19:38:26.247 10178-10183/com.example.my.app I/zygote64: After code cache collection, code=61KB, data=43KB
04-16 19:38:26.247 10178-10183/com.example.my.app I/zygote64: Increasing code cache capacity to 256KB
04-16 19:38:26.270 10178-10264/com.example.my.app W/VideoCapabilities: Unsupported mime video/mp4v-esdp
04-16 19:38:26.324 10178-10264/com.example.my.app I/VideoCapabilities: Unsupported profile 4 for video/mp4v-es
04-16 19:38:26.578 10178-10315/com.example.my.app W/cr_CrashFileManager: /data/user/0/com.example.my.app/cache/WebView/Crash Reports does not exist or is not a directory
04-16 19:38:26.579 10178-10178/com.example.my.app I/chromium: [INFO:CONSOLE(0)] "Document was loaded from Application Cache with manifest https://googleads.g.doubleclick.net/mads/static/mad/sdk/native/sdk-core-v40-loader.appcache", source: https://googleads.g.doubleclick.net/mads/static/mad/sdk/native/sdk-core-v40-loader.html (0)
04-16 19:38:26.580 10178-10178/com.example.my.app I/chromium: [INFO:CONSOLE(0)] "Application Cache Checking event", source: https://googleads.g.doubleclick.net/mads/static/mad/sdk/native/sdk-core-v40-loader.html (0)
04-16 19:38:26.746 10178-10288/com.example.my.app W/Ads: There was a problem getting an ad response. ErrorCode: 0
04-16 19:38:26.750 10178-10178/com.example.my.app W/Ads: Failed to load ad: 0
04-16 19:38:26.953 10178-10178/com.example.my.app I/chromium: [INFO:CONSOLE(0)] "Application Cache NoUpdate event", source: https://googleads.g.doubleclick.net/mads/static/mad/sdk/native/sdk-core-v40-loader.html (0)
04-16 19:38:48.880 10178-10178/com.example.my.app D/AppTracker: App Event: stop
04-16 19:41:11.526 10178-10178/com.example.my.app D/AppTracker: App Event: start
04-16 19:41:41.449 10178-10178/com.example.my.app D/AppTracker: App Event: stop

请帮我解决这个问题。

1 个答案:

答案 0 :(得分:0)

有时广告不匹配,并且不会显示。您应该将监听器添加到AdView并检查错误代码。

mAdView.setAdListener(new AdListener() {
    @Override
    public void onAdLoaded() {
        super.onAdLoaded();
         System.out.println("onAdLoaded() CALLBACK");
    }

    @Override
    public void onAdFailedToLoad(int errorCode) {
        super.onAdFailedToLoad(errorCode);
         System.out.println("onAdFailedToLoad() CALLBACK code: " + errorCode);
    }
});