Vungle with Admob mediation in Unity

925 Views Asked by At

i have integrated Admob 3.11.1 in Unity 2017.2.0 project. I wanted to add Vungle 5.3.2 as another network in the mediation.

  1. I have configured Vungle's console with an custom interstitial placement and rewarded custom placement.
  2. Succesfully added the Vungle's placement references into Admob console (as a new ad source).
  3. Configured eCPM of Vungle to $100 so it get first in priority.
  4. Imported Admob 3.11.1 Unity plugin.
  5. Imported vungle .jars from Android export and placed them in Plugins/Android folder. Also tried placing them in Plugins/Android/GoogleMobileAdsPlugin/libs.
  6. Added Vungle manifest activities.

<application
    android:icon="@drawable/app_icon"
    android:label="@string/app_name"
   android:theme="@android:style/Theme.NoTitleBar">
      <activity
    android:label="@string/app_name"
    android:screenOrientation="fullSensor"
    android:configChanges="keyboardHidden|orientation|screenSize|screenLayout|smallestScreenSize"
    android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
          android:name="com.vungle.publisher.VideoFullScreenAdActivity">
      </activity>
      <activity android:name="com.vungle.publisher.MraidFullScreenAdActivity"
     android:configChanges="keyboardHidden|orientation|screenSize|screenLayout|smallestScreenSize"
     android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen"/>
       <activity android:name="com.vungle.publisher.FlexViewAdActivity"
        android:configChanges="keyboardHidden|orientation|screenSize|screenLayout|smallestScreenSize"
        android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen"/>
  </application>
  
  <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"
        android:maxSdkVersion="18"/>
  <uses-permissio
        android:name="android.permission.READ_EXTERNAL_STORAGE"
        android:maxSdkVersion="18" />

  1. Load rewarded ad from script like this:

RewardBasedVideoAd rewardBasedVideo = RewardBasedVideoAd.Instance;

// Create an empty ad request.
AdRequest.Builder builder = new AdRequest.Builder();
// Add simulator test as default
builder.AddTestDevice(AdRequest.TestDeviceSimulator);

rewardBasedVideo.LoadAd(builder.Build(), "admob-rewarded-placement");

  1. I'm using proguard.. so i added the rules for Vungle:

# Vungle

-dontwarn com.vungle.**
-dontnote com.vungle.**
-keep class com.vungle.** { *; }
-keep class javax.inject.*

-dontwarn de.greenrobot.event.util.**

-dontwarn rx.internal.util.unsafe.**
-keepclassmembers class rx.internal.util.unsafe.*ArrayQueue*Field* {
   long producerIndex;
   long consumerIndex;
}
-keepclassmembers class rx.internal.util.unsafe.BaseLinkedQueueProducerNodeRef {
   rx.internal.util.atomic.LinkedQueueNode producerNode;
}
-keepclassmembers class rx.internal.util.unsafe.BaseLinkedQueueConsumerNodeRef {
   rx.internal.util.atomic.LinkedQueueNode consumerNode;
}
-keep class rx.schedulers.Schedulers { public static <methods>; }
-keep class rx.schedulers.ImmediateScheduler { public <methods>; }
-keep class rx.schedulers.TestScheduler { public <methods>; }
-keep class rx.schedulers.Schedulers { public static ** test(); }

-dontwarn com.moat.**
-keep class com.moat.** { public protected private *; }

-dontwarn okio.**
-dontwarn retrofit2.Platform$Java8

  1. Added Admob's Vungle adapter .aar in Plugins/Android folder.

When i want to show a rewarded ad, i allways get Admob ads or Unity ads (another network its being mediated). But i never get Vungle ads. What could i be missing?

1

There are 1 best solutions below

0
Nicolas Lorusso On

I finally solved it. I was missing passing Vungle placement references when loading Admob ad.

RewardBasedVideoAd rewardBasedVideo = RewardBasedVideoAd.Instance;
GoogleMobileAds.Api.Mediation.Vungle.VungleRewardedVideoMediationExtras vungle = new GoogleMobileAds.Api.Mediation.Vungle.VungleRewardedVideoMediationExtras();
vungle.SetAllPlacements(new string[] { "REWARDED-78375", "INTERSTITIAL_INGAME-243547", "DEFAULT8623" });

// Create an empty ad request.
AdRequest.Builder builder = new AdRequest.Builder()
 .AddMediationExtras(vungle);

// Add simulator test as default
builder.AddTestDevice(AdRequest.TestDeviceSimulator);

rewardBasedVideo.LoadAd(builder.Build(), m_rewardedVideoId);

I was also missing Vungle extras package. You can get it on Vungle tutorial about integration with Admob Tutorial