MoPub横幅广告或Intersitial:广告无法加载

时间:2018-07-06 14:06:04

标签: android ads interstitial mopub banner-ads

我遵循了MoPub的所有文档说明,但是我无法显示任何MoPub标语,或者非页内广告联系支持也无济于事。

我收到关于插页式广告或横幅广告的错误消息

07-06 20:57:12.465 14978-14978/? I/MoPub: Ad failed to load
07-06 20:57:16.415 14978-14978/? D/MoPub: No interstitial loading or loaded.

构建Gradle

implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support:cardview-v7:27.1.1'
implementation 'com.android.support:recyclerview-v7:27.1.1'
implementation 'com.android.support:support-v13:27.1.1'
implementation 'com.android.support:support-v4:27.1.1'

compile('com.mopub:mopub-sdk:5.0.0@aar') {
    transitive = true
}
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
implementation 'com.google.android.gms:play-services-base:15.0.1'
implementation 'com.google.android.gms:play-services-ads:15.0.1'

清单XML文件的权限和对话框

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

<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />

    

<!-- All ad formats -->
<activity android:name="com.mopub.common.MoPubBrowser" android:configChanges="keyboardHidden|orientation|screenSize"/>

<!-- Interstitials -->
<activity android:name="com.mopub.mobileads.MoPubActivity" android:configChanges="keyboardHidden|orientation|screenSize"/>
<activity android:name="com.mopub.mobileads.MraidActivity" android:configChanges="keyboardHidden|orientation|screenSize"/>

<!-- Rewarded Video and Rewarded Playables -->
<activity android:name="com.mopub.mobileads.RewardedMraidActivity" android:configChanges="keyboardHidden|orientation|screenSize"/>
<activity android:name="com.mopub.mobileads.MraidVideoPlayerActivity" android:configChanges="keyboardHidden|orientation|screenSize"/>


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

<activity
    android:name="com.google.android.gms.ads.AdActivity"
    android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
    android:theme="@android:style/Theme.Translucent" />

初始化

    SdkConfiguration sdkConfiguration = new SdkConfiguration.Builder("myIDunit")
            .build();
    MoPub.initializeSdk(this, sdkConfiguration, new SdkInitializationListener() {
        @Override
        public void onInitializationFinished() {
       /* MoPub SDK initialized.
       Check if you should show the consent dialog here, and make your ad requests. */
        }
    });

显示

mInterstitial = new MoPubInterstitial(getActivity(), "myID");
mInterstitial.load();

然后显示()

横幅

moPubView = (MoPubView) findViewById(R.id.adView_reward);
moPubView.setAdUnitId("myID");
moPubView.loadAd();

1 个答案:

答案 0 :(得分:0)

  1. 确保您没有在仪表板上配置错误
  2. 不要在SDK完成初始化之前发出广告请求

顺便说一句,您似乎没有将MoPubView添加到布局XML文件中