Search code examples
androidadsmopub

MoPub - Ad Failed to Load


I am confused with the error below, not sure where the mistake is, any help here is appreciated.

Code:

mopubView = (MoPubView) mainLayout.findViewById(R.id.mopubAdView);
mopubView.setAdUnitId("a19bd46992bc44c8959c13cc25f60e9c");
mopubView.setLayoutParams(params);
mopubView.loadAd();

View XML Code:

<com.mopub.mobileads.MoPubView
        android:id="@+id/mopubAdview"
        android:layout_width="fill_parent"
        android:layout_height="50dp" />

Glimpse of the manifest file:

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

<other settings />

<activity
    android:name="com.mopub.mobileads.MoPubActivity"
    android:configChanges="keyboardHidden|orientation" />
<activity
    android:name="com.mopub.mobileads.MraidActivity"
    android:configChanges="keyboardHidden|orientation" />
<activity
    android:name="com.mopub.common.MoPubBrowser"
    android:configChanges="keyboardHidden|orientation|screenSize" />
<activity
    android:name="com.mopub.mobileads.MraidBrowser"
    android:configChanges="keyboardHidden|orientation" />
<activity
    android:name="com.mopub.mobileads.MraidVideoPlayerActivity"
    android:configChanges="keyboardHidden|orientation" />
<activity
    android:name="com.google.ads.AdActivity"
    android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />
<activity
    android:name="com.millennialmedia.android.MMActivity"
    android:configChanges="keyboardHidden|orientation|keyboard"
    android:theme="@android:style/Theme.Translucent.NoTitleBar" />
<activity
    android:name="com.millennialmedia.android.VideoPlayer"
    android:configChanges="keyboardHidden|orientation|keyboard" />

Logcat Output

In AndroidManifest, the android:configChanges param is missing values for the following MoPub activities:
    The android:configChanges param for activity com.mopub.mobileads.MoPubActivity must include screenSize.
    The android:configChanges param for activity com.mopub.mobileads.MraidActivity must include screenSize.
    The android:configChanges param for activity com.mopub.mobileads.MraidVideoPlayerActivity must include screenSize.
Please update your manifest to include them.
In AndroidManifest, the android:configChanges param is missing values for the following MoPub activities:
    The android:configChanges param for activity com.mopub.mobileads.MoPubActivity must include screenSize.
    The android:configChanges param for activity com.mopub.mobileads.MraidActivity must include screenSize.
    The android:configChanges param for activity com.mopub.mobileads.MraidVideoPlayerActivity must include screenSize.
Please update your manifest to include them.
Loading url: http://ads.mopub.com/m/ad?v=6&id=a19bd46992bc44c8959c13cc25f60e9c&nv=3.3.0&dn=samsung%2CSAMSUNG-SGH-I337%2Cjflteuc&udid=ifa%3A937232dd-fa11-424f-94a0-f84897b305f4&ll=39.26126126126126%2C-84.33420242467194&lla=2000&llsdk=1&z=-0500&o=p&sc_a=3.0&mr=1&mcc=310&mnc=410&iso=us&cn=AT%26T&ct=2&av=1.02&android_perms_ext_storage=1&ts=1
Ad Unit (a19bd46992bc44c8959c13cc25f60e9c) is still warming up. Please try again in a few minutes.
Ad failed to load.

Solution

  • The below updates to the activities solved the problem, MoPub documentation doesn't say this, but when you bring the app, you will get this error, I have created an issue with MoPub to look into this and update their documentation if needed.

    <activity
        android:name="com.mopub.mobileads.MoPubActivity"
        android:configChanges="keyboardHidden|orientation|screenSize" />
    <activity
        android:name="com.mopub.mobileads.MraidActivity"
        android:configChanges="keyboardHidden|orientation|screenSize" />
    <activity
        android:name="com.mopub.common.MoPubBrowser"
        android:configChanges="keyboardHidden|orientation|screenSize" />
    <activity
        android:name="com.mopub.mobileads.MraidBrowser"
        android:configChanges="keyboardHidden|orientation|screenSize" />
    <activity
        android:name="com.mopub.mobileads.MraidVideoPlayerActivity"
        android:configChanges="keyboardHidden|orientation|screenSize" />
    <activity
        android:name="com.google.ads.AdActivity"
        android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />
    <activity
        android:name="com.millennialmedia.android.MMActivity"
        android:configChanges="keyboardHidden|orientation|keyboard"
        android:theme="@android:style/Theme.Translucent.NoTitleBar" />
    <activity
        android:name="com.millennialmedia.android.VideoPlayer"
        android:configChanges="keyboardHidden|orientation|keyboard" />
    

    UPDATE I had reported an issue with MoPub and the documentation on the mopub wiki has been updated - https://github.com/mopub/mopub-android-sdk/issues/134 looks like the owner of this repo does not allow any issues raised by the public