Mavl sdk V1.2. integrated guide - kevenzxd/GoodPractice GitHub Wiki
2. Update build gradle version
Remove mopub module from setting.gradle
- include ':mopub-sdk', ':mopub-sdk:mopub-sdk-base', ':mopub-sdk:mopub-sdk-banner',
- ':mopub-sdk:mopub-sdk-interstitial', ':mopub-sdk:mopub-sdk-rewardedvideo',
- ':mopub-sdk:mopub-sdk-native-static', ':mopub-sdk:mopub-sdk-native-video'
buildscript {
repositories {
google()
maven {
url "https://plugins.gradle.org/m2/"
}
jcenter()
maven { url "https://jitpack.io" }
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'
classpath 'com.google.gms:google-services:3.1.1'
}
}
Copy mavl-mopub-sdk-release-*.*.*.aar file into project folder, such as: libs folder
Add mavl-mopub-sdk-release-*.*.*.aar supported in build.gradle
repositories {
jcenter()
flatDir {
dirs './libs'
}
}
android {
dependencies {
implementation(name: 'mavl-mopub-sdk-release-*.*.*', ext: 'aar')
}
}
android {
dependencies {
...
// for mopub sdk -- begin
// Required: version
implementation 'com.mopub.volley:mopub-volley:2.0.0'
// for google firebase analytics
// Required: version: 15.0.1+
implementation 'com.google.firebase:firebase-core:15.0.2'
// Can use the version 17.1.1 of firebase-ads.
implementation 'com.google.firebase:firebase-ads:15.0.1'
implementation 'com.google.firebase:firebase-config:15.0.2'
// Required: version
implementation ("com.facebook.android:audience-network-sdk:5.1.0") {
transitive = true
exclude group: 'com.google.android.exoplayer', module: 'exoplayer'
exclude group: 'com.google.android.gms', module: 'play-services-ads'
}
// Required: version
implementation 'com.google.android.exoplayer:exoplayer:2.8.2'
// Required: libs
implementation 'com.android.support:support-annotations:27.1.1'
// Required: version: 26.+ ~ 27.+
implementation 'com.android.support:support-v4:27.1.1'
// Required: libs
implementation 'com.android.support:recyclerview-v7:27.1.1'
// Required: libs
implementation 'com.google.code.gson:gson:2.8.0'
// for mopub sdk -- end
...
}
}
<meta-data
android:name="com.facebook.sdk.ApplicationId"
android:value="@string/facebook_app_id" />
<!-- adsdk_app_id: 此应用ADSDK的AppID,请向变现运营索取-->
<meta-data
android:name="com.ad.sdk.appid"
android:value="@string/adsdk_app_id"/>
@Override
public void onCreate() {
AdSdkManager.getInstance()
.initialize(getApplicationContext(),
() -> AdSdkLog.v("zzz onInitializationFinished "));
}
@Override
public void onLowMemory() {
super.onLowMemory();
MavlSdkManager.getInstance().handleLowMemory();
// If use the config logic to load ad, should release ad resources when the memory is low.
for (QrAdConfig config: QrAdConfig.values()) {
AdLoadHelper.destroyAd(config);
}
}
-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}
-keep class com.google.gson.** { *; }
#============= For Mavl SDK ===================
-keep class com.mavlink.** {
*;
}
## Add it for log event
-keep class com.google.firebase.** { *; }
#============= End Mavl SDK ===================
-keep class com.mopub.** {
*;
}
-keep class com.facebook.**{
*;
}
##---------------Begin: proguard configuration for Google Play Service ----------
-keep class * extends java.util.ListResourceBundle {
protected Object[][] getContents();
}
-keep public class com.google.android.gms.common.internal.safeparcel.SafeParcelable {
public static final *** NULL;
}
-keepnames @com.google.android.gms.common.annotation.KeepName class *
-keepclassmembernames class * {
@com.google.android.gms.common.annotation.KeepName *;
}
-keepnames class * implements android.os.Parcelable {
public static final ** CREATOR;
}
##---------------End: proguard configuration for Google Play Service —————
If add flurry supported, do as following, if not, ignore step 6.1.
android {
dependencies {
...
// Add for flurry supported.
implementation (name: 'flurry-support-release-*.*.*', ext: 'aar')
// End for flurry supported.
...
}
}
##------------------------Start for Flurry--------------------
-keep class com.flurry.** {
*;
}
-dontwarn com.flurry.**
-keepattributes *Annotation*,EnclosingMethod,Signature
-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet, int);
}
# Google Play Services library
-keep class com.google.android.gms.** { *; }
-dontwarn com.google.android.gms.**
-keep class * extends java.util.ListResourceBundle {
protected Object[][] getContents();
}
-keep public class com.google.android.gms.common.internal.safeparcel.SafeParcelable {
public static final *** NULL;
}
-keepnames @com.google.android.gms.common.annotation.KeepName class *
-keepclassmembernames class * {
@com.google.android.gms.common.annotation.KeepName *;
}
-keepnames class * implements android.os.Parcelable {
public static final ** CREATOR;
}
##------------------------End for Flurry--------------------
If add Appmonet supported, do as following, if not, ignore step 6.2.
Add in project/build.gradle
allprojects {
repositories {
...
// add the private bintray repository
maven {
url "http://appmonet.bintray.com/MonetBidder"
// Apply the download account from account manager
credentials {
username '***************'
password '***************'
}
}
}
}
Add in app/build.gradle
android {
dependencies {
...
// Add for appmonet
implementation 'com.monet:appmonet-mopub:3.3.0@aar'
...
}
}
@Override
public void onCreate() {
AppMonetConfiguration config = new AppMonetConfiguration.Builder()
.applicationId(getResources().getString(R.string.appmonet_appid))
.disableBannerListener(true)
.build();
AppMonet.init(this, config);
}
##---------------------------Start for AppMonet--------------------------------
-keep public class com.monet.** {
public protected *;
native <methods>;
}
-keep public class android.support.v4.content.ContextCompat{public *;}
-keep public class android.webkit.JavascriptInterface
-keepclassmembers class fqcn.of.javascript.interface.for.webview {public *;}
## AppMonet Interstitial
-keep public class android.support.v7.app.AppCompatActivity{public *;}
-keep class android.support.v4.content.LocalBroadcastManager{*;}
-keep class android.support.v7.widget.** {*;}
-keep class android.support.v7.app.ActionBar{*;}
-keep class com.monet.bidder.core.*{
*;
}
##---------------------------End for AppMonet----------------------------------
<application>
...
<meta-data android:name="appmonet.application.id"
android:value="@string/appmonet_appId" />
...
</application>
If add AerServ supported, do as following, if not, ignore step 6.3.
Add in app/build.gradle
android {
dependencies {
...
// Add for AerServer
compile (name: 'aerserv-support-release-1.0.1', ext: 'aar')
// add for vungle
compile 'com.google.android.gms:play-services-basement:12.0.1'
compile 'com.google.android.gms:play-services-location:12.0.1'
// end for vungle
// add for Unity
compile (name: 'unity-ads', ext: 'aar')
// end for Unity
// Add for AerServer
...
}
}
<meta-data android:name="aerserver.app.id"
android:value="@string/aerserv_id" />
The AerServ AD is bind with activity, so should be register activity before requesting AerServ AD.
In Activity
@Override
protected void onCreate(Bundle savedInstanceState) {
...
MavlSdkManager.getInstance().initialize(this);
MavlSdkManager.getInstance().registerActivity(this);
...
}
@Override
protected void onDestroy() {
...
MavlSdkManager.getInstance().unRegisterActivity(this);
...
}
#============= Add for AerServer SDK ===================
-keepattributes *Annotation*
-keep public class * extends android.app.Activity
-keep public class * extends android.app.Application
-keep public class * extends android.app.Service
-keep public class * extends android.content.BroadcastReceiver
-keep public class * extends android.content.ContentProvider
-keep public class * extends android.view.View {
public <init>(android.content.Context);
public <init>(android.content.Context, android.util.AttributeSet);
public <init>(android.content.Context, android.util.AttributeSet, int);
public void set*(...);
}
-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet);
}
-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet, int);
}
-keepclassmembers class * extends android.content.Context {
public void *(android.view.View);
public void *(android.view.MenuItem);
}
-keepclassmembers class * implements android.os.Parcelable {
static ** CREATOR;
}
-keepclassmembers class **.R$* {
public static <fields>;
}
-keepclassmembers class * {
@android.webkit.JavascriptInterface <methods>;
}
-keep class android.support.v7.** {
public protected *;
}
-dontwarn com.google.android.gms.**
-keep class com.google.android.gms.** { *; }
-dontwarn javax.xml.**
# AerServ SDK
-keep class com.aerserv.** { *; }
-keepclassmembers class com.aerserv.** { *; }
# Moat
-dontwarn com.moat.**
#============= End for AerServer SDK ===================
# For Adcolony
-dontwarn android.webkit.**
-dontwarn com.adcolony.**
-keep class com.adcolony.sdk.* { *; }
# For Admob
-keep class com.google.android.gms.ads.** { *; }
# For Applovin
-dontwarn com.applovin.**
-keep class com.applovin.** { *; }
# For Unity Ads
-dontwarn com.unity3d.ads.**
-keep class com.unity3d.ads.** { *; }
# For Vungle
-dontwarn com.vungle.**
-dontnote com.vungle.**
-keep class com.vungle.** { *; }
-keep class javax.inject.*
# GreenRobot
-dontwarn de.greenrobot.event.util.**
# RxJava
-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(); }
# Retrofit
-dontwarn okio.**
-dontwarn retrofit2.Platform$Java8
# for GSON (Vungle)
-keepattributes Signature
-keep class sun.misc.Unsafe { *; }
-keep class com.google.gson.examples.android.model.** { *; }
# Retrofit
-dontwarn okio.**
-dontwarn retrofit2.Platform$Java8
# for GSON (Vungle)
-keepattributes Signature
-keep class sun.misc.Unsafe { *; }
-keep class com.google.gson.examples.android.model.** { *; }
If add Smatto supported, do as following, if not, ignore step 6.4.
copy smatto-support-release-..*.aar and somaandroid-9.1.4-release.aar files into project
android {
dependencies {
...
// Add for Smatto supported.
implementation (name: 'smatto-support-release-*.*.*', ext: 'aar')
implementation (name: 'somaandroid-9.1.4-release', ext:'aar')
// End for Smatto supported.
...
}
}
# Start for smatto
-assumenosideeffects class android.util.Log {
public static *** d(...);
public static *** v(...);
public static *** i(...);
}
-keep public class com.smaato.soma.** { *; }
-dontwarn com.smaato.soma.SomaUnityPlugin*
-dontwarn com.millennialmedia**
-dontwarn com.facebook.**
# End for smatto
If add APS supported, do as following, if not, ignore step 6.5.
copy amazon-support-release-..*.aar and DTBAndroidSDK-8.2.1.aar files into project
android {
dependencies {
...
// Add for APS
compile(name: 'amazon-support-release-*.*.*', ext: 'aar')
implementation 'com.amazon.android:aps-sdk:8.2.1@aar'
// End for Smatto supported.
...
}
}
-keep class com.amazon.device.ads.** { *; }
-keep class com.adsdk.aps.** { *; }
If add Fyber supported, do as following, if not, ignore step 6.6.
Add Fyber support from link: https://developer.inner-active.com/docs/integrating-android
提示:使用7.5.0版本// Feb. 25, 2020, updated
copy fyber-support-release-1...aar files into project
android {
dependencies {
...
// Add for Fyber
compile(name: 'fyber-support-release-1.*.*', ext: 'aar')
// End for Fyber supported.
...
}
}
If add Ogury supported, do as following, if not, ignore step 6.7.
Manual integration
Download sdk from MavlArsenal : ogury-mediation-mopub-4.1.5.aar : ogury-sdk-4.7.2.aar
dependencies {
implementation(name: 'ogury-sdk-4.7.2', ext: 'aar')
implementation(name: 'ogury-mediation-mopub-4.1.5', ext: 'aar')
}
Add follows code into Application.onCreate().
private final static String Ogury_App_ID = "OGY-xxxxxxxxxxxx";
private void initOgurySDK() {
Presage.getInstance().start(Ogury_App_ID, Context.this);
}
If add Criteo supported, do as following, if not, ignore step 6.8.
copy criteo-support-release-1.0.1-202002181514.aar + CriteoPublisherSdk_Android_v3.4.0_release.aar files into project
android {
dependencies {
...
// Add for Criteo
implementation (name:'CriteoPublisherSdk_Android_v3.4.0_release', ext:'aar')
implementation (name:'criteo-support-release-1.0.1-202002181514', ext:'aar')
// End for Criteo supported.
...
}
}
# Start for Criteo
-keep public class com.criteo.mediation.mopub.** { *; }
# End for Criteo
/**
* starting from version 4.26 of the Facebook SDK you can scan QR codes, so any version below that will not include the com.google.zxing group.
* https://developers.facebook.com/docs/android/change-log-4x#4_26_0
*/
implementation ("com.facebook.android:facebook-android-sdk:4.28.0") {
transitive = true
exclude group: 'com.google.zxing', module: 'core'
}