Я следовал всем инструкциям MoPub по документам, но я не могу отобразить ни один баннер MoPub, или поддержка внутренних контактов также не помогла.
У меня есть сообщение об ошибке для intersitial или banner
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();
, а затем показать ()
Banner
moPubView = (MoPubView) findViewById(R.id.adView_reward);
moPubView.setAdUnitId("myID");
moPubView.loadAd();