Mavl sdk V1.1.0 integrated guide - kevenzxd/GoodPractice GitHub Wiki
Content
2. Update build gradle version
Guide
Mavl aar V1.1.2 can support GMS AD 17.1.1.
1. Remove old mopub module
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'
2. Update build gradle version
buildscript {
repositories {
mavenCentral()
google()
jcenter()
}
dependencies {
// No need match the version 100%, but should build successfully.
classpath 'com.android.tools.build:gradle:3.1.4'
classpath 'com.google.gms:google-services:4.0.1'
}
}
allprojects {
repositories {
mavenCentral()
google()
jcenter()
}
}
3. Copy aar file
Copy mavl-mopub-sdk-release-*.*.*.aar file into project folder, such as: libs folder
4. Add aar file
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')
}
}
5. Add mavl sdk support
5.1 Add in app/build.gradle
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
...
}
}
5.2 Add google Gson file
5.3 Add in manifest
<meta-data
android:name="com.facebook.sdk.ApplicationId"
android:value="@string/facebook_app_id" />
5.4 Add in AppApplication
@Override
public void onCreate() {
MavlSdkManager.getInstance().initialize(Context);
}
@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);
}
}
5.5 Add in proguard file
-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}
-keep class com.google.gson.** { *; }
#============= For Mavl SDK ===================
-keep class com.mavlink.** {
*;
}
#============= 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 —————