Android Integration

MAS supports Android version 4.4.+ (Android API level: 19+) and above

1. Open your Project-Level build.gradle  and add the repositories

Use the code below to integrate the standard SDK.

				
					allprojects {
   repositories {
       google()
       jcenter()
       mavenCentral()
       maven { url 'https://artifact.bytedance.com/repository/pangle' }
       maven { url 'https://android-sdk.is.com' }
       maven { url 'https://sdk.tapjoy.com/' }
   }
}
				
			


Use the code below if you need to reduce the size of the build. This version has fewer ad networks than the standard SDK.

				
					allprojects {
   repositories {
       google()
       jcenter()
       mavenCentral()
   }
}
				
			


Use the code below if you need to comply with the Google Family Policy.

				
					allprojects {
   repositories {
       google()
       jcenter()
       mavenCentral()
       maven { url 'https://android-sdk.is.com' }
       maven { url 'https://sdk.tapjoy.com/' }
   }
}
				
			


2. Open Your App-Level build.gradle and add the following

1. If you’re only targeting children under 13 years of age, please add this Gradle dependency:

				
					implementation 'com.yodo1.mas:google:4.6.0'
				
			


2. If you’re targeting all ages, or 13+, use this Gradle dependency:

				
					implementation 'com.yodo1.mas:full:4.6.0'
				
			


3. Add MultiDex property to the defaultConfig Section

				
					defaultConfig {
    ...
    multiDexEnabled true
    ...
}
				
			


4. Make sure that minSdkVersion is at least 19 in the defaultConfig Section.

				
					defaultConfig {
   ...
   minSdkVersion 19
   ...
}
				
			


3. Support AndroidX

Add this content to the gradle.properties file:

				
					android.useAndroidX=true
android.enableJetifier=true
android.enableDexingArtifactTransform=false
				
			


4. Update your AndroidManifest.xml file

1. Add your AdMob App ID to your app’s AndroidManifest.xml file by including the  tag. Your AdMob App ID can be found under the “details” of your app on MAS Dashboard. Please replace android:value with your own AdMob App ID:

				
					
	
	
				
			


2. Add the following line to the manifest tag.

				
					xmlns:tools="http://schemas.android.com/tools"
				
			


3. Add the following lines to the application tag.

				
					tools:replace="android:label"
tools:targetApi="n"
				
			


5. Place FlutterYodo1Mas under the same directory as MainActivity

1. Download the file here.

2. Add the following line at the top of this file. Make sure to replace the package name.

				
					package com.companyname.projectname;
				
			


6. Update your MainActivity file

1. Add these libraries at the top.

				
					import android.os.Bundle;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import io.flutter.embedding.android.FlutterActivity;
import io.flutter.embedding.engine.FlutterEngine;
				
			

2. Add these methods in MainActivity.

@Override
protected void onCreate(@Nullable Bundle savedInstanceState)
{ 
super.onCreate(savedInstanceState);
}
@Override
public void configureFlutterEngine(@NonNull FlutterEngine flutterEngine) {
super.configureFlutterEngine(flutterEngine);
FlutterYodo1Mas.getInstance().build(flutterEngine, this);
}
override fun onCreate(savedInstanceState: Bundle?) { 
super.onCreate(savedInstanceState)
}
override fun configureFlutterEngine(flutterEngine: FlutterEngine) {
super.configureFlutterEngine(flut terEngine)
FlutterYodo1Mas.getInstance()?.build(flutterEngine, this)
}

7. Place Yodo1Mas.dart under the same directory as main.dart

Download the file here.

Custom privacy dialog

When you use your own privacy dialog :

  • If the user’s age >= 13, then set COPPA to false, otherwise set it to true.
  • If the user’s age >= 16 and consents to having his data collected, then set GDPR to true, otherwise set it to false.
  • If the user consents to having his data collected, then set CCPA to false, otherwise set it to true.

You’ll find the details about how to set the legal frameworks through these links:

MAS privacy dialog

You can enable the built-in privacy compliance dialog to collect the users’ age and consent.

1. Enable (Before the initialization)

Yodo1MasAdBuildConfig config = new
Yodo1MasAdBuildConfig.Builder().enableUserPrivacyDialog(true).build();
Yodo1Mas.getInstance().setAdBuildConfig(config);
val config = Yodo1MasAdBuildConfig.Builder().enableUserPrivacyDialog(true).build()
Yodo1Mas.getInstance().setAdBuildConfig(config)

2. Custom user agreement (optional)

Yodo1MasAdBuildConfig config = new
Yodo1MasAdBuildConfig.Builder().enableUserPrivacyDialog(true).userAgreementUrl("Your user agreement url").build();    
Yodo1Mas.getInstance().setAdBuildConfig(config);
val config =
Yodo1MasAdBuildConfig.Builder().enableUserPrivacyDialog(true).userAgreementUrl("Your user agreement url").build()
Yodo1Mas.getInstance().setAdBuildConfig(config)

3. Custom privacy policy (optional)

Yodo1MasAdBuildConfig config = new
Yodo1MasAdBuildConfig.Builder().enableUserPrivacyDialog(true).privacyPolicyUrl("Your privacy policy url").build();    
Yodo1Mas.getInstance().setAdBuildConfig(config);
val config =
Yodo1MasAdBuildConfig.Builder().enableUserPrivacyDialog(true).privacyPolicyUrl("Your privacy policy url").build();
Yodo1Mas.getInstance().setAdBuildConfig(config);

9. Initialize the SDK

Initialize the SDK in the main.dart file. This call can be made in the  MyHomePageState class constructor. Also, make sure to import Yodo1Mas.dart in this file.

				
					Yodo1Mas.instance.init("Your app key", (successful) {
});
				
			

 

  • Note: Please use your Appkey for initialization, not the Admob App ID. Your Appkey can be found under the “details” of your app on MAS Dashboard.

10. Show the ads

You can use the following methods for the different types of ads.

Show a banner

				
					Yodo1Mas.instance.showBannerAd();
				
			


Hide a banner

				
					Yodo1Mas.instance.dismissBannerAd();
				
			


Show an interstitial

				
					Yodo1Mas.instance.showInterstitialAd();
				
			

Show a rewarded video
 
				
					Yodo1Mas.instance.showRewardAd();
				
			

 

11. Set Delegates

For the banners

				
					Yodo1Mas.instance.setBannerListener((event, message) {
switch(event) {
case Yodo1Mas.AD_EVENT_OPENED:
print('Banner AD_EVENT_OPENED');
break;
case Yodo1Mas.AD_EVENT_ERROR:
print('Banner AD_EVENT_ERROR' + message);
break;
case Yodo1Mas.AD_EVENT_CLOSED:
print('Banner AD_EVENT_CLOSED');
break;
}
});
				
			


For the interstitials

				
					Yodo1Mas.instance.setInterstitialListener((event, message) {
 switch(event) {
   case Yodo1Mas.AD_EVENT_OPENED:
     print('Interstitial AD_EVENT_OPENED');
     break;
   case Yodo1Mas.AD_EVENT_ERROR:
     print('Interstitial AD_EVENT_ERROR' + message);
     break;
   case Yodo1Mas.AD_EVENT_CLOSED:
     print('Interstitial AD_EVENT_CLOSED');
     break;
 }
});
				
			


For the rewarded videos

 

				
					Yodo1Mas.instance.setRewardListener((event, message) {
switch(event) {
case Yodo1Mas.AD_EVENT_OPENED:
print('RewardVideo AD_EVENT_OPENED');
break;
case Yodo1Mas.AD_EVENT_ERROR:
print('RewardVideo AD_EVENT_ERROR' + message);
break;
case Yodo1Mas.AD_EVENT_CLOSED:
print('RewardVideo AD_EVENT_CLOSED');
break;
case Yodo1Mas.AD_EVENT_EARNED:
print('RewardVideo AD_EVENT_EARNED');
break;
}
});
				
			

12. ProGuard

If you’re using ProGuard with the MAS SDK, add the following code to your ProGuard file (Android Studio: proguard-rules.pro or Eclipse: proguard-project.txt): Download the file here.

For the next step please test your integration

CONTENTS