MoPub Ads Library

Pendrush

Well-Known Member
Licensed User
Longtime User
Original library: https://developers.mopub.com/publishers/android/
Based on MoPub Android SDK 5.15.0 (November 18, 2020)
Banner, Interstitial and Rewarded Video Ads (untested).

Currently is not possible to use this library with B4a.


MoPubAds

Author:
Author: MoPub - B4a Wrapper: Pendrush
Version: 5.15
  • MoPubBanner
    • Events:
      • BannerClicked
      • BannerCollapsed
      • BannerExpanded
      • BannerFailed (Error As String)
      • BannerInitialized
      • BannerLoaded
    • Fields:
      • AD_BANNER_HEIGHT_50 As Object
      • AD_BANNER_HEIGHT_90 As Object
    • Functions:
      • BringToFront
      • DestroyAd
        Destroy Ad
      • Initialize (arg1 As String)
      • InitializeBanner (EventName As String, UnitId As String, ForceGdprApplies As Boolean)
        Initialize Banner Ad
        MoPubBanner1.InitializeBanner("MoPubBanner1", "b195f8dd8ded45fe847ad89ed1d016da", False)
        ForceGdprApplies - explanation
        If the publisher is not using the forceGDPRApplies flag, consent is considered valid where isGDPRApplicable is true as defined by MoPub.
        If a publisher then starts using the forceGDPRApplies flag for a user not identified by MoPub as being subject to GDPR,
        our SDK will treat that user as subject to GDPR for the duration of the app lifetime.
        If the publisher is using the forceGDPRApplies flag, consent is valid for users for whom the forceGDPRApplies flag is on.
        If, in a later update, the publisher decides that they no longer want to use the forceGDPRApplies flag, new users will be treated as subject to GDPR as determined by MoPub,
        and any existing users for whom the forceGDPRApplies flag was previously set will still be treated as subject to GDPR as defined by publisher.
        This cannot be revoked by any means except with app deletion and re-installation.
      • Invalidate
      • Invalidate2 (arg0 As android.graphics.Rect)
      • Invalidate3 (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)
      • IsInitialized As Boolean
      • LoadAd (BannerAdHeight As com.mopub.mobileads.MoPubView.MoPubAdSize)
        Load Ad in event BannerInitialized or after, not before BannerInitialized fire.
        MoPubBanner1.LoadAd(MoPubBanner1.AD_BANNER_HEIGHT_50)
      • OpenConsentDialogForced
        OpenConsentDialogForced is valid in event BannerInitialized or after, not before BannerInitialized fire
        Dialog will open if you ForceGdprApplies in InitializeBanner method, or if user is in EEA zone.
      • RemoveView
      • RequestFocus As Boolean
      • SendToBack
      • SetBackgroundImage (arg0 As android.graphics.Bitmap) As BitmapDrawable
      • SetColorAnimated (arg0 As Int, arg1 As Int, arg2 As Int)
      • SetLayout (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)
      • SetLayoutAnimated (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int, arg4 As Int)
      • SetVisibleAnimated (arg0 As Int, arg1 As Boolean)
    • Properties:
      • Background As android.graphics.drawable.Drawable
      • CollectPersonalInformation As Boolean [read only]
        CollectPersonalInformation is valid in event BannerInitialized or after, not before BannerInitialized fire.
        If True, can collect personal information. User select Yes on Gdpr consent dialog, or not in EEA zone.
      • Color As Int [write only]
      • Enabled As Boolean
      • GdprApplies As Boolean [read only]
        GdprApplies is valid in event BannerInitialized or after, not before BannerInitialized fire.
        True if user is in EEA zone.
      • Height As Int
      • Left As Int
      • Padding As Int()
      • Parent As Object [read only]
      • Tag As Object
      • Top As Int
      • Visible As Boolean
      • Width As Int
  • MoPubInterstitial
    • Events:
      • InterstitialClicked
      • InterstitialDismissed
      • InterstitialFailed (Error As String)
      • InterstitialLoaded
      • InterstitialShown
    • Functions:
      • DestroyAd
        Destroy Ad
      • InitializeInterstitial (EventName As String, UnitId As String)
        Initialize Interstitial Ad in event BannerInitialized or after, not before BannerInitialized fire.
        MoPubInterstitial1.InitializeInterstitial("MoPubInterstitial1", "24534e1901884e398f1253216226017e")
        MoPubInterstitial1.LoadAd
      • IsReady As Boolean
        IsReady, return True if Interstitial Ad is ready to be shown.
      • LoadAd
        Load Interstitial Ad in event BannerInitialized or after, not before BannerInitialized fire.
        MoPubInterstitial1.LoadAd
      • ShowAd
        Show Ad.
  • MoPubRewardedVideo
    • Events:
      • RewardedVideoClicked
      • RewardedVideoClosed
      • RewardedVideoCompleted (Successful As Boolean, Label As String, Amount As Int)
      • RewardedVideoLoadFailure (Error As String)
      • RewardedVideoLoadSuccess
      • RewardedVideoPlaybackError (Error As String)
      • RewardedVideoStarted
    • Functions:
      • HasRewardedVideo As Boolean
        Return True if Rewarded Video Ad is ready to be shown.
      • InitializeRewarded (EventName As String, UnitId As String)
        Initialize Rewarded Video Ad.
        MoPubRewardedVideo1.InitializeRewarded("MoPubRewardedVideo1", "920b6145fb1546cf8b5cf2ac34638bb7")
      • LoadRewardedVideo
        Load Rewarded Video Ad.
      • ShowRewardedVideo
        Show Rewarded Video Ad.

MoPub, a Twitter company, provides monetization solutions for mobile app publishers and developers around the globe. Our flexible network mediation solution, leading mobile programmatic exchange, and years of expertise in mobile app advertising mean publishers trust us to help them maximize their ad revenue and control their user experience.

This library can mediate AdMob and Facebook Audience Network trough MoPub implemented adapters.
That means 3 large networks, AdMob, Facebook and Marketplace (Mopub) compete each other for higher eCPM price = more profit for you. Network with higher ad price will show ad in your app. At any time you have full control what where and how will be shown in your app. Turning on/off some of these network in your live app is just one click away in MoPub dashboard.
If you want to use one of the best mediation network in mobile world, then use MoPub as you can customize everything, including Back fill, Direct sold ads and much much more.

Download library zip file from this link and extract archive to Additional Libraries folder. I'm not able to upload on forum, as size of file is over maximum allowed limit.

MoPub library depend on files from Facebook Audience Network Library. You need to have files in Additional Libraries folder, no need to include FAN library in your project.

v5.13 - Check manifest in MoPubExample. Manifest have some breaking changes from previous version.
v5.15 - Rewarded Video Ads, Manifest update. I'm not able to test Rewarded Video Ads. You can try by follow these steps.
 

Attachments

  • MoPubExample.zip
    12.1 KB · Views: 339
Last edited:

DonManfred

Expert
Licensed User
Longtime User
@DonManfred this is an AD library, maybe you need to reconsider your like
Even if i do not like (i hate) Ads.... The Like is for providing the lib to anyone. A small Honor for your work ;-) ....
 
Last edited:

hl88

Member
compile no error, but show "app not installed" on Android 10 phone
I got 3 files mopub-sdk-base, mopub-sdk-banner and mopub-sdk-fullscreen version 5.14. will edit the file mopubAds.xml works?
1602578085106.png
 
Last edited:

Schakalaka

Active Member
Licensed User
Longtime User
Original library: https://developers.mopub.com/publishers/android/
Based on MoPub Android SDK 5.13.1 (July 6, 2020)
Banner and Interstitial Ads.




This library can mediate AdMob and Facebook Audience Network trough MoPub implemented adapters.
That means 3 large networks, AdMob, Facebook and Marketplace (Mopub) compete each other for higher eCPM price = more profit for you. Network with higher ad price will show ad in your app. At any time you have full control what where and how will be shown in your app. Turning on/off some of these network in your live app is just one click away in MoPub dashboard.
If you want to use one of the best mediation network in mobile world, then use MoPub as you can customize everything, including Back fill, Direct sold ads and much much more.

Download library zip file from this link and extract archive to Additional Libraries folder. I'm not able to upload on forum, as size of file is over maximum allowed limit.

MoPub library depend on files from Facebook Audience Network Library. You need to have files in Additional Libraries folder, no need to include FAN library in your project.

v5.13 - Check manifest in MoPubExample. Manifest have some breaking changes from previous version.
hello.
any way for add rewards video? (since this version are "fullscreen" (check changelog)

i have collect all last files, but some are missing (maybe need to create custom with android studio? (i'm not able to do)


B4X:
https://drive.google.com/file/d/1jNrzIdtz_tiiWIxpZF0GRPwcEsC8v9mZ/view?usp=sharing

These are the missing files:
File List:
MoPubAds.jar [No Find]

MoPubAds.xml [No Find]

MoPubMerged.jar [No Find]
 

Murilo Besse

Member
Licensed User
Longtime User
Hi,
I'm trying to use mopub ads, but sometimes when loading intersticial ad I got this error: "java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/gson/GsonBuilder;"

Test ads works fine.
 

Pendrush

Well-Known Member
Licensed User
Longtime User
Hi,
I'm trying to use mopub ads, but sometimes when loading intersticial ad I got this error: "java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/gson/GsonBuilder;"

Test ads works fine.
You can test new, just published, version.
 

Murilo Besse

Member
Licensed User
Longtime User
Thanks for the update!

I've downloaded the new version, but GsonBuilder error showed again.
Adding #AdditionalJar: gson-2.8.5 seems to solve this error, but there's a new one now.

"Failed resolution of: Landroidx/media2/player/MediaPlayer;"
It happens when I click on Show Intersticial Ad.
 

Pendrush

Well-Known Member
Licensed User
Longtime User
You should add:
B4X:
#AdditionalJar: androidx.media2:media2-session
#AdditionalJar: androidx.media2:media2-widget
#AdditionalJar: androidx.media2:media2-player
#AdditionalJar: androidx.core:core-ktx
But this will not work as you need to do desugar first.
I'm not able to do it. This what I get:
extract
merge
desugar
Exception in thread "main" java.lang.NoClassDefFoundError: androidx/concurrent/futures/AbstractResolvableFuture
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:756)
at java.lang.ClassLoader.defineClass(ClassLoader.java:635)
at com.google.devtools.build.android.desugar.io.HeaderClassLoader.findClass(HeaderClassLoader.java:67)
at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:756)
at java.lang.ClassLoader.defineClass(ClassLoader.java:635)
at com.google.devtools.build.android.desugar.io.HeaderClassLoader.findClass(HeaderClassLoader.java:67)
at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
at com.google.devtools.build.android.desugar.LambdaDesugaring.loadFromInternal(LambdaDesugaring.java:337)
at com.google.devtools.build.android.desugar.LambdaDesugaring.access$500(LambdaDesugaring.java:56)
at com.google.devtools.build.android.desugar.LambdaDesugaring$InvokedynamicRewriter.createLookup(LambdaDesugaring.java:620)
at com.google.devtools.build.android.desugar.LambdaDesugaring$InvokedynamicRewriter.visitInvokeDynamicInsn(LambdaDesugaring.java:402)
at org.objectweb.asm.ClassReader.readCode(ClassReader.java:2235)
at org.objectweb.asm.ClassReader.readMethod(ClassReader.java:1275)
at org.objectweb.asm.ClassReader.accept(ClassReader.java:679)
at org.objectweb.asm.ClassReader.accept(ClassReader.java:391)
at com.google.devtools.build.android.desugar.Desugar.desugarClassesInInput(Desugar.java:618)
at com.google.devtools.build.android.desugar.Desugar.desugarOneInput(Desugar.java:449)
at com.google.devtools.build.android.desugar.Desugar.desugar(Desugar.java:391)
at com.google.devtools.build.android.desugar.Desugar.main(Desugar.java:974)
Caused by: java.lang.ClassNotFoundException: Class androidx.concurrent.futures.AbstractResolvableFuture not found
at com.google.devtools.build.android.desugar.io.HeaderClassLoader.findClass(HeaderClassLoader.java:53)
at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
... 24 more
1
 

tufanv

Expert
Licensed User
Longtime User
is this working or not?
Original library: https://developers.mopub.com/publishers/android/
Based on MoPub Android SDK 5.15.0 (November 18, 2020)
Banner, Interstitial and Rewarded Video Ads (untested).

Currently is not possible to use this library with B4a.





This library can mediate AdMob and Facebook Audience Network trough MoPub implemented adapters.
That means 3 large networks, AdMob, Facebook and Marketplace (Mopub) compete each other for higher eCPM price = more profit for you. Network with higher ad price will show ad in your app. At any time you have full control what where and how will be shown in your app. Turning on/off some of these network in your live app is just one click away in MoPub dashboard.
If you want to use one of the best mediation network in mobile world, then use MoPub as you can customize everything, including Back fill, Direct sold ads and much much more.

Download library zip file from this link and extract archive to Additional Libraries folder. I'm not able to upload on forum, as size of file is over maximum allowed limit.

MoPub library depend on files from Facebook Audience Network Library. You need to have files in Additional Libraries folder, no need to include FAN library in your project.

v5.13 - Check manifest in MoPubExample. Manifest have some breaking changes from previous version.
v5.15 - Rewarded Video Ads, Manifest update. I'm not able to test Rewarded Video Ads. You can try by follow these steps.
 
Top