B4A Library MoPub Ad Server Library (Updated to v4.6.1 , 29 May 2016) - 20+ ad networks (AdMob , etc.)

mopub_logo.png

Library (Updated to v4.6.1 , 29 May 2016)
MoPub Official Website
Google Play Policies
MoPub is the world largest mobile ad server (mediation platform) and RTB exchange (MoPub marketplace). Now it belongs to Twitter. It is the main competitor to AdMob , but MoPub primary focus is mediation of ads. The following ad networks work just right out of the box:
MoPubLibVer.png

support.PNG
All networks are tested and use official java code of these networks.
AdColony can use only interstitial or rewarded video, if you will use both in your project - it will not work.
Tapjoy - please test, integration is rather complicated, so for now I didn't test it myself, but normally it should work.
Native ads are not supported for now.
Note: I advise you to use logcat logs in B4A (without filter checked) or this standalone utility to see all error codes and a lot of additional info about loading your ads.

Please vote for ad network you want to see in MoPub Library


ChangeLog:
v4.6.1 29.05.2016
v4.2 30.11.2015

Updated:
MoPub SDK v4.2 (Nov 30,2015)
All ad networks SDK's and code
Syntax of using library is changed a little
Added:
Rewarded video ads
Amazon ads
Tapjoy
Unity ads

v2.3 22.07.2014
Updated:
MoPub SDK v2.3 (Jul 17, 2014)
All ad networks SDKs
Added:
mNectar
MobileCore
Facebook
AdColony
Vungle
StartApp
Leadbolt

v2.1 02.12.2013
Added:
AppLovin (banners and interstitials)
Greystripe (banners and interstitials)
Chartboost (interstitials)

v2.0 28.11.2013
Added :
Banners and interstitials listeners
Interstitials' preload - now all works really fast
Integrated AppBrain and TapForTap
(both banners and interstitials)
Updated:
MoPub SDK v1.17 (Nov 20, 2013)
Appbrain SDK v9.2
TapForTap SDK v3.0.7
Fixed:
Interstitial's close button
Almost totally rewrited library

v1.1 16.06.2013
Added:
Interstitial ads

Roadmap:
Add support for Madvertise , RevMob , AppNext , Inneractive , TapContext , Amazon Ads , Flurry , MobPartner , MDotm
Note: possibly to make wrapper for MobFox as alternative to MoPub , because as from May 14, 2014 their SDK supports custom events to integrate other networks SDK , also maybe wrapper for mAdserve as self-hosting solution for mediating ads.


Tags: MoPub , MobFox , Mojiva , Lifestreet media , Hunt mobile ads , Tapit , AdMob , Millennial Media , Inmobi , Chartboost , Greystripe , AppBrain , TapForTap , MobileCore , AppLovin , Leadbolt , Facebook , AdColony , Vungle , StartApp , mNectar , Ad Network Library

Links:
MoPub B4A v4.6.1 update (Updated 29 May 2016)
MoPub B4A Library v4.2 Additional SDK's (Updated 30 November 2015)
I have included demo project with all listener methodes. You can compile that project with default id's to test ads.
Also I have written detailed but simple as possible guide to integrate all of the networks and general help how to use MoPub.
Soon I will update guide and published it, for now please see demo project.

Good luck !
Regards
John


 

Attachments

  • MoPub B4A Library v4.2.zip
    451.5 KB · Views: 558
Last edited:

jalle007

Active Member
Licensed User
Longtime User
Hi John
Have 2 questions , if you could answer
1. my country is not on the listed (i registered under US and sent support inquiry on how to switch to my coutnry)
2. how do i integrate appbrain account with mopub ? I can not see anywhere in mopub dashboard where to enter this info.
 

Johnmcenroy

Active Member
Licensed User
Longtime User
Hi Jalle
Sorry for delay
1. Hope they will help you with country , they pay normally by paypal.
2. All networks (AppBrain and others) that are not listed in their ad networks , you can add by choosing Custom Native Network (networks supported by library) and Custom Networks (networks that give you javascript code such as Leadbolt for example).
3.MoPub banner ID you get when you make new application with new ad , for example banner 320x50. There is no AppBrain ID , all your applications you must add in AppBrain console.

It seems maybe complicated but this is for the first time. Please download help guide for more info.

Regards
John
 

MaxApps

Active Member
Licensed User
Longtime User
Hi John

I have just received the Leadbolt Mopub SDK Adaptor.
Is it possible to use this together with your library?

Kind regards
Jakob
 

susu

Well-Known Member
Licensed User
Longtime User
Hi John,

Could you please update your great library to use newest MoPub SDK? Thank you so much.
 

jalle007

Active Member
Licensed User
Longtime User
Hi John

Thanks to a comprehensive response.
Yet I still struggle with setting Mopuba in my app.

Here is the code :

B4X:
Sub Activity_Create(FirstTime As Boolean)

......

    ads.InitializeMopub_Banner("banner","1f4fa25e691643c49aad47e41ae8544b")
  ads.PreloadMopub_Interstitial("interstitial","1f4fa25e691643c49aad47e41ae8544b")
    ads.RemoveView
    Activity.AddView (ads,0,100%y-50dip,320dip,50dip)
    ads.LoadMopub_Banner
    ads.ShowMopub_Interstitial
End Sub

and error I am receiving in my logcat.: "Banner Failed"

The thing is, I've created an Ad Unit on Mopub but I did not choose any Ad network to show in that banner.
How do I do this please ?

Edit: and the manifest file looks like this
B4X:
AddManifestText(
<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="14"/>
<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" />
<supports-screens android:largeScreens="true"
    android:normalScreens="true"
    android:smallScreens="true"
    android:anyDensity="true"/>)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
'End of default text.

AddApplicationText(<receiver android:name="com.jalle.HumanitarniTelefon.ReEngagement" />)
AddApplicationText(<service android:name="com.jalle.HumanitarniTelefon.ReEngagementService" />)


AddApplicationText(
<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.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:theme="@android:style/Theme.Translucent.NoTitleBar" android:configChanges="keyboardHidden|orientation|keyboard" />
<activity android:name="com.millennialmedia.android.VideoPlayer" android:configChanges="keyboardHidden|orientation|keyboard" />

<!-- AppBrain SDK -->
<activity android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
    android:name="com.appbrain.AppBrainActivity" />
<service android:name="com.appbrain.AppBrainService" />       
<receiver android:exported="true" android:name="com.appbrain.ReferrerReceiver" >
    <intent-filter>
        <action android:name="com.android.vending.INSTALL_REFERRER" />
    </intent-filter>
</receiver>
<activity android:name="com.tapfortap.FullScreenAdActivity" android:theme="@android:style/Theme.Translucent.NoTitleBar"/>
)
Hi Jalle
Sorry for delay
1. Hope they will help you with country , they pay normally by paypal.
2. All networks (AppBrain and others) that are not listed in their ad networks , you can add by choosing Custom Native Network (networks supported by library) and Custom Networks (networks that give you javascript code such as Leadbolt for example).
3.MoPub banner ID you get when you make new application with new ad , for example banner 320x50. There is no AppBrain ID , all your applications you must add in AppBrain console.

It seems maybe complicated but this is for the first time. Please download help guide for more info.

Regards
John
 

jalle007

Active Member
Licensed User
Longtime User
I have some progress, ad is showing in the app
but when I click on it I get error:

B4X:
Got the error: Bad Request
while trying to obtain /m/aclk?accid=1ab9aa67c8e9427a81ad7713512aa512&c=a71b3f349cb846f39fc9524c9c91c4fb&req=1e38c1cec94211e39395002590d55dd7&cpid=c81180d70dba45a6a63ca5921657ad1a&hourly=0&reqt=1398077156.0&cid=a71b3f349cb846f39fc9524c9c91c4fb&click_hourly=0&real_appid=f83155b2eaa947578df5b80e587879c2&daily=0&agid=05dac04bc5d64ae4a5cc22e791b5f5db&click_daily=0&appid=&mpx_clk=http%3A%2F%2Fcpp.imp.mpx.mopub.com%2Fclick%3Fad_domain%3Dtsmobileforandroidphone.fxcm.com%26adgroup_id%3D05dac04bc5d64ae4a5cc22e791b5f5db%26adunit_id%3D168bbeb272fd4e9cbd860773741cd8ee%26ads_creative_id%3Da71b3f349cb846f39fc9524c9c91c4fb%26app_id%3Df83155b2eaa947578df5b80e587879c2%26app_name%3DHumanitarni%2520Telefon%26auction_time%3D1398077156%26bid_price%3D0.22%26bidder_id%3D3ad28e7wMB%26bidder_name%3DFlurry%26campaign_id%3Dc81180d70dba45a6a63ca5921657ad1a%26charge_price%3D0.1%26ck%3DE9896%26ckenc%3D2%26country%3DBIH%26creative_id%3D29423-320x50%26currency%3DUSD%26impression_id%3Db9700796-2546-4de3-ac61-900ed04903bb%26laten&r=http%3A%2F%2Fad.flurry.com%2F
GET /m/aclk?accid=1ab9aa67c8e9427a81ad7713512aa512&c=a71b3f349cb846f39fc9524c9c91c4fb&req=1e38c1cec94211e39395002590d55dd7&cpid=c81180d70dba45a6a63ca5921657ad1a&hourly=0&reqt=1398077156.0&cid=a71b3f349cb846f39fc9524c9c91c4fb&click_hourly=0&real_appid=f83155b2eaa947578df5b80e587879c2&daily=0&agid=05dac04bc5d64ae4a5cc22e791b5f5db&click_daily=0&appid=&mpx_clk=http%3A%2F%2Fcpp.imp.mpx.mopub.com%2Fclick%3Fad_domain%3Dtsmobileforandroidphone.fxcm.com%26adgroup_id%3D05dac04bc5d64ae4a5cc22e791b5f5db%26adunit_id%3D168bbeb272fd4e9cbd860773741cd8ee%26ads_creative_id%3Da71b3f349cb846f39fc9524c9c91c4fb%26app_id%3Df83155b2eaa947578df5b80e587879c2%26app_name%3DHumanitarni%2520Telefon%26auction_time%3D1398077156%26bid_price%3D0.22%26bidder_id%3D3ad28e7wMB%26bidder_name%3DFlurry%26campaign_id%3Dc81180d70dba45a6a63ca5921657ad1a%26charge_price%3D0.1%26ck%3DE9896%26ckenc%3D2%26country%3DBIH%26creative_id%3D29423-320x50%26currency%3DUSD%26impression_id%3Db9700796-2546-4de3-ac61-900ed04903bb%26laten&r=http%3A%2F%2Fad.flurry.com%2F
 

Johnmcenroy

Active Member
Licensed User
Longtime User
Hi Jalle
You can pass "" empty string to test banner load and how it works.
Banner failed can be if there is no ad for your country , you must add more
ad networks in "NETWORKS" tab or add your own ad in "ORDERS" tab.
What concerns your ad , it seems that something is wrong to get an ad.
I highly recommend to read MoPub startup guide.

Regards
John

Hi John

Thanks to a comprehensive response.
Yet I still struggle with setting Mopuba in my app.

Here is the code :

B4X:
Sub Activity_Create(FirstTime As Boolean)

......

    ads.InitializeMopub_Banner("banner","1f4fa25e691643c49aad47e41ae8544b")
  ads.PreloadMopub_Interstitial("interstitial","1f4fa25e691643c49aad47e41ae8544b")
    ads.RemoveView
    Activity.AddView (ads,0,100%y-50dip,320dip,50dip)
    ads.LoadMopub_Banner
    ads.ShowMopub_Interstitial
End Sub

and error I am receiving in my logcat.: "Banner Failed"

The thing is, I've created an Ad Unit on Mopub but I did not choose any Ad network to show in that banner.
How do I do this please ?

Edit: and the manifest file looks like this
B4X:
AddManifestText(
<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="14"/>
<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" />
<supports-screens android:largeScreens="true"
    android:normalScreens="true"
    android:smallScreens="true"
    android:anyDensity="true"/>)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
'End of default text.

AddApplicationText(<receiver android:name="com.jalle.HumanitarniTelefon.ReEngagement" />)
AddApplicationText(<service android:name="com.jalle.HumanitarniTelefon.ReEngagementService" />)


AddApplicationText(
<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.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:theme="@android:style/Theme.Translucent.NoTitleBar" android:configChanges="keyboardHidden|orientation|keyboard" />
<activity android:name="com.millennialmedia.android.VideoPlayer" android:configChanges="keyboardHidden|orientation|keyboard" />

<!-- AppBrain SDK -->
<activity android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
    android:name="com.appbrain.AppBrainActivity" />
<service android:name="com.appbrain.AppBrainService" />  
<receiver android:exported="true" android:name="com.appbrain.ReferrerReceiver" >
    <intent-filter>
        <action android:name="com.android.vending.INSTALL_REFERRER" />
    </intent-filter>
</receiver>
<activity android:name="com.tapfortap.FullScreenAdActivity" android:theme="@android:style/Theme.Translucent.NoTitleBar"/>
)
 
Last edited:

MaxApps

Active Member
Licensed User
Longtime User
Hi John

Any chance of an update, to the newest SDK?
I heard from a friend, that his income increased a lot, with the new SDK

Kind regards
Jakob
 

jalle007

Active Member
Licensed User
Longtime User
HI,

Really have no luck with this Mopub :-/
I was able to show interstitial one but after that they disappeared

B4X:
'ads.InitializeMopub_Banner("banner","168bbeb272fd4e9cbd860773741cd8ee")
    ads.InitializeMopub_Banner("","")
  ads.PreloadMopub_Interstitial("interstitial","1f4fa25e691643c49aad47e41ae8544b")
    ads.RemoveView
  'Activity.AddView (ads,0,100%y-50dip,320dip,50dip)
    'ads.LoadMopub_Banner

End Sub

'Interstitials Listener methodes
Sub interstitial_mopub_interstitial_loaded
    LogColor("Interstitial Loaded",Colors.Blue)
    ads.ShowMopub_Interstitial
End Sub

Thus, I need only interstitials
Attached are my Mopub & Admob settings for this app.

There in mopub are Humanitarni: BAnner ad and Fullscreen Ad.
For publisher ID I took Mediation ID fro mAdmob
as that is what I have been told by Mopub support.
ANW if I try to set publisher ID from admob then its the same error:

Banner failed
and no error at all for Interestrials.


HEEEEELP :D


Edit: here is the email conv from Moppub but there either I dont know what he is talking about
Mopub support:
"Couple of items to consider. Wondering the credentials you are using from AdMob cause you should be using your AdMob's 'Ad Unit ID' and not the 'Legacy Publisher ID.' I know it may be confusing as within MoPub's dashboard it mentions to have the 'Publisher ID' but really it should be the 'Ad Unit ID' from AdMob that should be entered."
 

Attachments

  • admob1.png
    admob1.png
    48.3 KB · Views: 268
  • mopub1.png
    mopub1.png
    40.6 KB · Views: 258

Jack Cole

Well-Known Member
Licensed User
Longtime User
Hi John,

Thank you for this library. There are a couple things that I would suggest. You don't need to include the android-support-v4 or Google Admob sdk in the XML. Admob is natively supported within mopub, so the SDK is not needed for admob at all.

For others like me who don't want all the extra SDK's, you can simply remove the dependsOn settings for everything but mopub-sdk.

Best regards,
Jack
 

elbelli2013

Member
Licensed User
Longtime User
Hi Jhon, I've one question:

Why when I initialize and add view, the memory consuption grow at least 100%?
For example, when I not use MoPub library, my application only use 8 mb, but when I try to use de library my application use 25mb of memory?

thanks in advance.
 

Johnmcenroy

Active Member
Licensed User
Longtime User
Hi John,

Thank you for this library. There are a couple things that I would suggest. You don't need to include the android-support-v4 or Google Admob sdk in the XML. Admob is natively supported within mopub, so the SDK is not needed for admob at all.

For others like me who don't want all the extra SDK's, you can simply remove the dependsOn settings for everything but mopub-sdk.

Best regards,
Jack

Hi Jack
Yes Admob is supported natively but it needs SDK and from august 1 , 2014 admob sdk is not supported for new applications and updated. Instead of Admob SDK there is Google Play Services SDK.
https://github.com/mopub/mopub-android-sdk/wiki/Integrating-Third-Party-Ad-Networks

Soon I will update to MoPub SDK 2.2 and make a guide , because it seems a bit complicated for now.

Regards
John
 
Last edited:

Johnmcenroy

Active Member
Licensed User
Longtime User
Hi Jhon, I've one question:

Why when I initialize and add view, the memory consuption grow at least 100%?
For example, when I not use MoPub library, my application only use 8 mb, but when I try to use de library my application use 25mb of memory?

thanks in advance.

Hi Elbelli
Soon I will update to MoPub SDK 2.2 , please check then if there is such a problem.
 
Top