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


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:

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



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: 577
Last edited:

Inman

Well-Known Member
Licensed User
Longtime User
I get this error on compilation when I tried to add InMobi mediation via Mopub
B4X:
Parsing code.                          0.36
Compiling code.                        0.31
Compiling layouts code.                0.01
Generating R file.                      1.91
Compiling generated Java code.          5.08
Convert byte code - optimized dex.      Error
UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.IllegalArgumentException: already added: Lcom/inmobi/monetization/IMInterstitial$b;
    at com.android.dx.dex.file.ClassDefsSection.add(ClassDefsSection.java:123)
    at com.android.dx.dex.file.DexFile.add(DexFile.java:163)
    at com.android.dx.command.dexer.Main.processClass(Main.java:490)
    at com.android.dx.command.dexer.Main.processFileBytes(Main.java:459)
    at com.android.dx.command.dexer.Main.access$400(Main.java:67)
    at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:398)
    at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:245)
    at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:131)
    at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:109)
    at com.android.dx.command.dexer.Main.processOne(Main.java:422)
    at com.android.dx.command.dexer.Main.processAllFiles(Main.java:333)
    at com.android.dx.command.dexer.Main.run(Main.java:209)
    at com.android.dx.command.dexer.Main.main(Main.java:174)
    at com.android.dx.command.Main.main(Main.java:91)
1 error; aborting
    Optimized dexer failed. Switching to Standard dexer.

Here is what I did. I put InMobi-4.4.2.jar file in the folder that contains mopub library. I opened mopub.xml and uncommented <dependsOn>InMobi-4.4.2</dependsOn> line. I also added the AddApplicationText lines for InMobi.

What could be wrong?
 

Johnmcenroy

Active Member
Licensed User
Longtime User

It seems that InMobi jar have been added to project , try to clean project. Also you can try to set MaxRamForDex in B4A ini file here:
C:\Users\<Your user name>\AppData\Roaming\Anywhere Software\Basic4android
to 1024mb or 1536mb

Regards
John
 
Last edited:

Inman

Well-Known Member
Licensed User
Longtime User
You are right. The problem was that I had included the original Admob library in the project and in the Admob.xml there was a dependson to InMobi jar file, to enable InMobi mediation via Admob. Once I unchecked Admob library, it compiles without error.
 

Inman

Well-Known Member
Licensed User
Longtime User
As you know, the "Advertising ID" policy of Google came into force on August 1st. All third party ad SDKs should use Advertising ID to prevent the app from getting banned from Play Store.

Are all the ad network jar files in the zip file, compatible with the Advertising ID policy? I am not sure which all networks have implemented this (that too from which version of their SDKs) but I found a list online.

https://docs.google.com/spreadsheets/d/1uVuJP4Graub6dlechARDyZowEPHnGaHEkge9VQhnBoQ/edit#gid=0
 

manolitoGnet

Member
Licensed User
Longtime User
There is a joke in spanish language... In two words: in credible.

A really nice job, well documented and fully functional for me in a few hours. I just started testing MoPub and it works like a charm.

Thanks John!

Hay un chiste por aquí... En dos palabras: "im" "prezionante" (Muñegote de Jesulín de Ubrique)

Un trabajo esplendido, bien documentado y completamente funcional para mi en unas horas. Acabo de empezar el testing de MoPub y me está funcionando de maravilla.

Gracias John!
 

manolitoGnet

Member
Licensed User
Longtime User
Hi John,

I'm compiling my testMoPub app without the google services jar,
B4X:
'#AdditionalRes: C:\Program Files (x86)\Android\android-sdk\extras\google\google_play_services\libproject\google-play-services_lib\res, com.google.android.gms

and it seems to work properly and small, Is it really necesary if you don't have any plans to connect with AdMob?

Thanks in advance,

Roman
 

Johnmcenroy

Active Member
Licensed User
Longtime User

Hi Roman
Thanks for kind words. Happy that you like it.
What concerns Google Play Services:
"Requirements and Dependencies
The MoPub SDK requires Android version 2.2 or greater. It also depends on the Android v4 support library and we strongly recommend compiling your app against the Google Play Services Library in order to use the Android Advertising ID instead of the device ID, as required by Google. Failing to correctly use the Android Advertising ID may result in your submission to the Play Store being rejected."
https://github.com/mopub/mopub-android-sdk/wiki/Getting-Started

Regards
John
 

Inman

Well-Known Member
Licensed User
Longtime User
I am trying to display Mopub Interstitial and I got this error which resulted in the crashed exit of the app. What could be wrong?

B4X:
** Activity (main) Resume **


java.lang.NoClassDefFoundError: com.zqmjvmxgugakeytipeno.AdController


    at com.mopub.mobileads.LeadboltInterstitial.loadInterstitial(LeadboltInterstitial.java:79)
    at com.mopub.mobileads.CustomEventInterstitialAdapter.loadInterstitial(CustomEventInterstitialAdapter.java:114)
    at com.mopub.mobileads.MoPubInterstitial$MoPubInterstitialView.loadCustomEvent(MoPubInterstitial.java:309)
    at com.mopub.mobileads.AdLoadTask$CustomEventAdLoadTask.execute(AdLoadTask.java:200)
    at com.mopub.mobileads.AdFetchTask.onPostExecute(AdFetchTask.java:220)
    at com.mopub.mobileads.AdFetchTask.onPostExecute(AdFetchTask.java:1)
    at android.os.AsyncTask.finish(AsyncTask.java:632)
    at android.os.AsyncTask.access$600(AsyncTask.java:177)
    at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:645)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:136)
    at android.app.ActivityThread.main(ActivityThread.java:5050)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:515)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:605)
    at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:132)
    at dalvik.system.NativeStart.main(Native Method)
 

Johnmcenroy

Active Member
Licensed User
Longtime User

Hi Inman
It seems that you didn't added LeadBolt SDK in MoPub XML file or through #AdditionalJar: LeadBolt (only for B4A 3.80+)

Regards
John
 

Inman

Well-Known Member
Licensed User
Longtime User
No I did add it via Mopub XML. In fact Leadbolt banner ads worked fine until I started testing interstitials, causing the app to crash.
 

Johnmcenroy

Active Member
Licensed User
Longtime User
No I did add it via Mopub XML. In fact Leadbolt banner ads worked fine until I started testing interstitials, causing the app to crash.

Normal Leadbolt banners (MoPub banner unit) works through MoPub custom network (javascript code) and Leadbolt banners and interstitials via Custom Native Network is only for MoPub fullscreen unit. Your error indicate that it can't find LeadBolt SDK. Try redownload MoPub library , maybe you have another Leadbolt SDK. Leadbolt through MoPub work only with certain Leadbolt SDK , because of certain package name in their java code. In your example this is
com.zqmjvmxgugakeytipeno.

Regards
John
 
Last edited:

Inman

Well-Known Member
Licensed User
Longtime User
Alright I fixed it. A few days back I had downloaded Leadbolt SDK from their site and replaced Leadbolt.jar file you provided, with the downloaded file. I think that caused the issue. Now I reverted back to the file you included and it is working correctly.
 

Inman

Well-Known Member
Licensed User
Longtime User
Is it possible to know if PreloadMopub_Interstitial has indeed preloaded an interstitial for displaying?
 

Johnmcenroy

Active Member
Licensed User
Longtime User
Is it possible to know if PreloadMopub_Interstitial has indeed preloaded an interstitial for displaying?

Yes. All listeners methodes are in example project. What you need is :
B4X:
Sub interstitial_mopub_interstitial_loaded
    LogColor("Interstitial Loaded",Colors.Blue)
End Sub

But not all ad networks support all listeners methods. You must check it in LogCat. As a rule interstitial_loaded method is supported by all networks.

Regards
John
 

Inman

Well-Known Member
Licensed User
Longtime User
Thanks John. Any reason you didn't include these methods in the autocomplete list of B4A IDE?
 

Inman

Well-Known Member
Licensed User
Longtime User
After I rolled back to your version of Leadbolt.jar, I keep getting a notification on the Leadbolt site saying SDK Update Required to v6.4. If I use the latest SDK from LeadBolt site, I get the error mentioned previously. Could you please take a look?
 

Johnmcenroy

Active Member
Licensed User
Longtime User

Please use for now my Leadbolt SDK version (6.3). I will update later MoPub Library so user can download himself Leadbolt SDK from their website and update guide for instructions.

Also you can do it now in more complicated way :
1) Download Leadbolt SDK zip archive.
2) Copy Leadbolt SDK and MoPub adapter to additional B4A Libraries folder.
3) Add Leadbolt SDK and Leadbolt MoPub adapter jar's to your MoPub.XML or through #AdditionalJar attribute (B4A 3.80+)
4) In MoPub custom native web interface for Leadbolt you must enter the package name of MoPub Leadbolt Adapter (You can see it with JD-GUI by opening this jar. You can download it here - http://jd.benow.ca)

Update: I have checked myself the package name for Leadbolt MoPub adapter v6.4. For now it is com.mopub.mobileads.

Regards
John
 
Last edited:

Inman

Well-Known Member
Licensed User
Longtime User
That's ok, I will use your version for now. I was worried that the latest SDK might be needed to make it compatible with Google Advertising ID policy but turns out LeadBolt made the change for v6.3 and above.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…