ConsoliAds Mediation Integration

You are here:
Estimated reading time: 11 min

Download Mediation Native SDK

Download ConsoliAds Android Mediation SDK here and download the required Ad Networks SDKs here

Create App on Portal

Login to your ConsoliAds portal and go to Apps-> New App to create your native app.

Make sure that you have already created a brand to associate your app with. Import your app directly from the app store or create manually by providing all the required information and save, ConsoliAds will create your app with the following default placeholders:
•   Activity 1
•   Activity 2
•   Activity 3
•   Activity 4
•   Options A
•   Options B
•   About
•   Settings

Integrating ConsoliAds Mediation

After downloading ConsoliAds mediation SDK, copy all ‘.aar’ files to your android project inside “libs” folder. Please create “libs” folder inside your Android Studio app if it does not exists.

To add your desired Ad Network to ConsoliAds mediation, please visit Add/Remove Ad Network‘ section.

Open your Project level “build.gradle” write following under allprojects -> repositories section:

flatDir { dirs ‘libs’ }

Open your app level “build.gradle” and write the following line in the dependencies section to import ConsoliAds mediation:


implementation(name: 'consoliadsmediation', ext: 'aar')

implementation(name: 'consoliads-mediation', ext: 'aar')

implementation(name: 'consoliadsplugin', ext: 'aar')

implementation(name: 'loaderlibrary', ext: 'aar')

ConsoliAds Mediation Dependencies

ConsoliAds mediation requires following libraries as dependencies. Open your app level “build.gradle” and add following dependencies:

implementation 'com.android.support.constraint:constraint-layout:1.1.2'
implementation 'com.google.android.gms:play-services-ads:17.2.1'
implementation 'com.google.android.gms:play-services-basement:16.0.1'
implementation 'com.google.android.gms:play-services-ads-identifier:16.0.0'
implementation 'com.google.android.gms:play-services-location:16.0.0'
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support:support-v4:26.1.0'
implementation 'com.android.support:cardview-v7:26.1.0'
implementation 'com.android.support:recyclerview-v7:26.1.0'
implementation 'com.google.code.gson:gson:2.8.5'

 

Initializing ConsoliAds Mediation

Before initializing ConsoliAds mediation, you need to make sure that the app is created on ConsoliAds dashboard (go to the section New App on portal). For initializing ConsoliAds mediation, you need to provide your app’s Product Name and Bundle Identifier as follows:

ConsoliAds.Instance().productName = “Fitness Guide";
ConsoliAds.Instance().bundleIdentifier = “com.mystudio.fitnessguide";

Please import the required packages for the above (HINT: click on above line then press (Alt + Enter) to make instant import).

ConsoliAds also provides callbacks for events such as initialization, native ad loaded, etc. Your activity needs to extend the abstract class  “ConsoliAdsListener” and override your required callback methods to receive event callbacks and register callback events as follows:

private class Listener extends ConsoliAdsListener        {

}

Now register the class as follows:

ConsoliAds.Instance().setConsoliAdsListener(new Listener());

Initialize ConsoliAds mediation by:

ConsoliAds.Instance().initialize(true,this);

This call requires the following mandatory parameters:
          User Consent
TRUE means user has provided the consent and will be shown personalized ads, whereas FALSE means user is not willing to see personalized ads. It is developer’s responsibility to get user consent and pass it above initialization call.
          Activity
The prevailing Activity upon initialization.
Note: You have to make sure that you have integrated ConsoliAds SDK for ConsoliAds mediation to work properly otherwise your app will crash. See section: Add/Remove Networks->Integrating ConsoliAds SDK.

Interstitial Ad

Once initialized, ConsoliAds mediation is ready to show ads.

•  Login to your ConsoliAds portal and go to Apps->Mediation-> (Your APP)->Placeholders & Ads
•  Add Interstitial and Video Ad slot as shown in the below figure:

Make sure you have added Ad Network’s IDs in the portal for the corresponding app. Now show interstitial ad simply by the following code:
NOTE: Interstitial ads are not required to be requested and loaded separately.

ConsoliAds.Instance().ShowInterstitial(sceneIndex, Activity);

This call requires the following mandatory parameters:
Scene Index
Integer value for the index of the scene for which you want to show the Interstitial ad. As an example you should call above method with ‘0’ as scene index if you want to invoke the ad on your first scene regardless of its name.
Activity
The prevailing Activity when showing the interstitial ad.

Rewarded Video

•  Login to your ConsoliAds portal and go to Apps->Mediation-> (Your APP)->Placeholders & Ads
•  Add Rewarded Video Ad slot as shown in the below figure:

Load Rewarded Video

Rewarded video ads in ConsoliAds are loaded and shown separately. Load rewarded video ad as follows:

ConsoliAds.Instance().LoadRewarded(sceneIndex);

NOTE: It is highly recommended that you call LoadRewarded(sceneIndex) as early as possible to allow videos to be preloaded.
This call requires:
    • Scene Index
Integer value for the index of the scene for which you want to load the Rewarded video ad. As an example you should call above method with ‘0’ as scene index if you want to invoke the ad on your first scene regardless of its name.

Show Rewarded Video

Show Rewarded ad by simply the following code:

ConsoliAds.Instance().ShowRewardedVideo(sceneIndex , Activity);

This call requires the following two parameters:
Scene Index
Integer value for the index of the scene for which you want to show the Rewarded Video ad. As an example you should call above method with ‘0’ as scene index if you want to invoke the ad on your first scene regardless of its name.
Activity
The prevailing Activity when showing the Rewarded Video ad.

NOTE: To check call back events, go to the section ‘Events Callbacks’ below.

Banner Ad

•  Login to your ConsoliAds portal and go to Apps->Mediation-> (Your APP)->Placeholders & Ads
•  Add Banner Ad slot as shown in the below figure:

Show banner ad by simply the following code:

ConsoliAds.Instance().ShowBanner(sceneIndex, Activity);

This call requires the following two parameters:
Scene Index
Integer value for the index of the scene for which you want to show the Banner Ad. As an example you should call above method with ‘0’ as scene index if you want to invoke the ad on your first scene regardless of its name.
Activity
The prevailing Activity when showing the banner ad.
NOTE: ConsoliAds mediation supports one banner per activity.

Native Ad

ConsoliAds is the platform that helps you integrate Native Ads from different ad networks. It follows two approaches:

Single Native Integration – native ad for a single placeholder
Multiple Native Integration – native ad on a list activity

•  Login to your ConsoliAds portal and go to Apps->Mediation-> (Your APP)->Placeholders & Ads
•  Add Native Ad slot as shown in the below figure:

Show Single Native Ad
Single native ad integration configures the display content and let’s ConsoliAds handle ad placement.
Admob
o  Configure Admob Native Ad
Add FrameLayout in xml and reference it in your activity and pass that FrameLayout to Configure Method as :

FrameLayout nativeFrameLayout = findViewById(R.id.admob_native_frame);
ConsoliAds.Instance().ConfigureAdmobNativeAd(currentScene , nativeFrameLayout);

o Show Admob Native Ad

ConsoliAds.Instance().ShowNativeAd(currentScene , this);

• Facebook
o Configure Facebook Native Ad
Add required widgets in xml and reference it in your activity and pass them to Configure Method as :

LinearLayout adView = findViewById(R.id.ad_unit);
LinearLayout adChoicesContainer = adView.findViewById(R.id.ad_choices_container);
AdIconView nativeAdIcon = adView.findViewById(R.id.native_ad_icon);
TextView nativeAdTitle = adView.findViewById(R.id.native_ad_title);
MediaView nativeAdMedia = adView.findViewById(R.id.native_ad_media);
TextView nativeAdSocialContext = adView.findViewById(R.id.native_ad_social_context);
TextView nativeAdBody = adView.findViewById(R.id.native_ad_body);
TextView sponsoredLabel = adView.findViewById(R.id.native_ad_sponsored_label);
Button nativeAdCallToAction = adView.findViewById(R.id.native_ad_call_to_action);
ConsoliAds.Instance().ConfigureFacebookNativeAd(currentScene,adView ,adChoicesContainer,nativeAdIcon ,nativeAdTitle,nativeAdMedia,nativeAdSocialContext,nativeAdBody,sponsoredLabel,nativeAdCallToAction);

o Show Facebook Native Ad

ConsoliAds.Instance().ShowNativeAd(currentScene , this);

•  ConsoliAds
o Configure ConsoliAds Native Ad
Add required widgets in xml and reference it in your activity and pass them to Configure Method as :

LinearLayout adContainer = (LinearLayout) findViewById(R.id.native_container);
TextView adTitle = (TextView) findViewById(R.id.tv_ad_title);
TextView adSubTitle = (TextView) findViewById(R.id.tv_ad_sub_title);
TextView adDescription = (TextView) findViewById(R.id.tv_ad_description);
ImageView adImage = (ImageView) findViewById(R.id.iv_ad_image);
AdChoices adChoices = (AdChoices) findViewById(R.id.native_adchoices_main);
ActionButton actionButton = (ActionButton) findViewById(R.id.native_action_button);
ConsoliAds.Instance().ConfigureConsoliadsNativeAd(currentScene,adContainer,adChoices,adTitle,adSubTitle,adDescripti n,adImage,actionButton);

o Show ConsoliAds Native Ad

ConsoliAds.Instance().ShowNativeAd(currentScene , this);

•  AppLovin
o Configure AppLovin Native Ad
Add required widgets in xml and reference it in your activity and pass them to Configure Method as:

LinearLayout adView = findViewById( R.id.parent_container );
ImageView appRating = findViewById( R.id.appRating );
TextView appTitleTextView = findViewById( R.id.appTitleTextView );
TextView appDescriptionTextView = findViewById( R.id.appDescriptionTextV iew );
FrameLayout mediaViewPlaceholder = findViewById( R.id.mediaViewPlaceholder );
ImageView appIcon = findViewById( R.id.appIcon );
Button appDownloadButton = findViewById( R.id.appDownloadButton );
ConsoliAds.Instance().ConfigureApplovinNativeAd(sceneID,adView,appIcon,appRating,appTitleTextView,appDescriptio nTextView,appDownloadButton,mediaViewPlaceholder);

o Show AppLovin Native Ad

ConsoliAds.Instance().ShowNativeAd(currentScene , this);

•  Mintegral
o Configure Mintegral Native Ad
Add required widgets in xml and reference it in your activity and pass them to Configure Method as:

LinearLayout mItemView = findViewById(R.id.mintegral_feeds_ll_root);
MTGMediaView mMediaview = findViewById(R.id.mintegral_mediaview);
ImageView mIvIcon = findViewById(R.id.mintegral_feeds_icon);
TextView mTvAppName = findViewById(R.id.mintegral_feeds_app_name);
TextView mTvCta = findViewById(R.id.mintegral_feeds_tv_cta);
TextView mTvAppDesc = findViewById(R.id.mintegral_feeds_app_desc);
StarLevelLayoutView mStarLayout = findViewById(R.id.mintegral_feeds_star);
MTGAdChoice mAdChoice = findViewById(R.id.mintegral_mediaview_adchoice);
ConsoliAds.Instance().ConfigureMintegralNativeAd(sceneID,mItemView,mMediaview,mIvIcon,mTvAppName, mTvAppDesc,mTvCta,mAdChoice,mStarLayout );

o Show Mintegral Native Ad

ConsoliAds.Instance().ShowNativeAd(currentScene , this);

•  Mopub
o Configure Mopub Native Ad
Add required widgets in xml and reference it in your activity and pass them to Configure Method as:

FrameLayout adFrame = findViewById(R.id.native_frame);
ViewBinder viewBinder = new ViewBinder.Builder(R.layout.view_mopub_ad_view)
.titleId(R.id.native_title)
.textId(R.id.native_text)
.mainImageId(R.id.native_main_image)
.iconImageId(R.id.native_icon_image)
.callToActionId(R.id.native_cta)
.privacyInformationIconImageId(R.id.native_privacy_information_icon_image)
.build();
ConsoliAds.Instance().ConfigureMopubNativeAd(sceneID , adFrame , viewBinder);

o Show Mopub Native Ad

ConsoliAds.Instance().ShowNativeAd(currentScene , this);

•  Inmobi
o Configure Inmobi Native Ad
Add required widgets in xml and reference it in your activity and pass them to Configure Method as:

LinearLayout inmobi_container = findViewById( R.id.inmobi_ad_container );
ImageView inmobi_adIcon = findViewById( R.id.inmobi_adIcon );
FrameLayout inmobi_adContent = findViewById( R.id.inmobi_adContent );
TextView inmobi_adSponsored = findViewById( R.id.inmobi_adSponsored );
TextView inmobi_adTitle = findViewById( R.id.inmobi_adTitle );
RatingBar inmobi_adRating = findViewById( R.id.inmobi_adRating );
TextView inmobi_adAction = findViewById( R.id.inmobi_adAction );
TextView inmobi_adDescription = findViewById( R.id.inmobi_adDescription );
ConsoliAds.Instance().ConfigureInmobiNativeAd(sceneID,inmobi_container,inmobi_adIcon,inmobi_adSponsored,inmobi _adTitle,inmobi_adRating,inmobi_adContent,inmobi_adAction,inmobi_adDescription);

o Show Inmobi Native Ad

ConsoliAds.Instance().ShowNativeAd(currentScene , this);

•  Leadbolt
o Configure Leadbolt Native Ad
Add required widgets in xml and reference it in your activity and pass them to Configure Method as:

RelativeLayout relativeLayoutContainer = findViewById(R.id.native_ad_container);
TextView adTitle = findViewById(R.id.title);
TextView adDescription = findViewById(R.id.description);
Button actionButton = findViewById(R.id.action_button);
ImageView mediaImageView = findViewById(R.id.media_image);
ImageView iconImageView = findViewById(R.id.icon_image);
ConsoliAds.Instance().ConfigureLeadboltNativeAd(sceneID,relativeLayoutContainer,adTitle,adDescription,actionButton, mediaImageView,iconImageView);

o Show Leadbolt Native Ad

ConsoliAds.Instance().ShowNativeAd(currentScene , this);

•  Mobfox
o Configure Mobfox Native Ad
Add required widgets in xml and reference it in your activity and pass them to Configure Method as:

ConstraintLayout nativeLayout = findViewById(R.id.nativeLayout);
TextView nativeHeadline = findViewById(R.id.nativeheadline);
TextView nativeDesc = findViewById(R.id.nativedesc);
ImageView nativeIcon = findViewById(R.id.nativeIcon);
ImageView nativeMainImg = findViewById(R.id.nativeMainImg);
Button nativeCta = findViewById(R.id.nativecta);
ConsoliAds.Instance().ConfigureMobfoxNativeAd(sceneID , nativeLayout,nativeHeadline,nativeDesc,nativeIcon,nativeMainImg,nativeCta);

o Show Mobfox Native Ad

ConsoliAds.Instance().ShowNativeAd(currentScene , this);

•  MyTarget
o Configure MyTarget Native Ad
Add required widgets in xml and reference it in your activity and pass them to Configure Method as:

FrameLayout mytarget_frame = findViewById(R.id.mytarget_frame);
ConsoliAds.Instance().ConfigureMyTargetNativeAd(sceneID , mytarget_frame);

o Show MyTarget Native Ad

ConsoliAds.Instance().ShowNativeAd(currentScene , this);

•  StartApp
o Configure StartApp Native Ad
Add required widgets in xml and reference it in your activity and pass them to Configure Method as:

RelativeLayout stContainer = findViewById(R.id.st_native_ad_container);
TextView stTitle = findViewById(R.id.st_title);
TextView stDescription = findViewById(R.id.st_description);
ImageView stMainImageView = findViewById(R.id.st_media_image);
ImageView stIconImageView = findViewById(R.id.st_icon_image);
ConsoliAds.Instance().ConfigureStartAppNativeAd(sceneID,stContainer,stTitle,stDescription,stMainImageView,stIconImageView);

o Show StartApp Native Ad

ConsoliAds.Instance().ShowNativeAd(currentScene , this);

Note: XML structure for Native ad of every Ad Network is present in “XML STUCTURE FOR NATIVE ADS” section below.
Events to listen for Native Ads:

1. public void onNativeAdLoadedEvent(AdNetworkName adNetworkName, int index)
2. public void onNativeAdFailedToLoadEvent(AdNetworkName adNetworkName, int index)

Multiple Native Ads
1. Loading native ads:

ConsoliAds.Instance().addNativeAd(SceneIndex);

Scene Index
Integer value for the index of the scene for which you want to show the native ad. As an example you should call above method with ‘0’ as scene index if you want to invoke the ad on your first scene regardless of its name.

Note: To load multiple native ads on the same scene, call the above method multiple times.
2. Native Ad Loaded Callback

Your activity needs to extend the class “ConsoliAdsListener” to receive event callbacks.
Following event is invoked when Native ad is loaded:

@Override
public void onNativeAdLoadedEvent(AdNetworkName adNetworkName, int index)

•  adNetworkName: enum for ad type.
• index: index of the ad (index for the first addNativeAd call would be 1 and would be 2 for the next call)

3. Get Native Ad
Get the native ad for a specific Index:

ConsoliAds.Instance().getNativeAdAtIndex(int SceneIndex , int AdIndex)

• Scene Index :Integer value for the index of the scene for which you want to show the native ad. As an example you should call above method with ‘0’ as scene index if you want to invoke the ad on your first scene regardless of its name.

• AdIndex :Integer value for the index of the ad for which you want to get native ad.
To use Typecast the object returned by getNativeAdAtIndex and check for null as follows:

NativeAd nativeAd = (NativeAd) ConsoliAds.Instance().getNativeAdAtIndex(0 , i); if(nativeAd != null) { 

4. Native Ad Failure Callback
Following event is invoked when Native ad loading is failed:

@Override
public void onNativeAdFailedToLoadEvent(AdNetworkName adNetworkName, int index) { }

Load multiple Native Ads for Mopub:

FrameLayout adFrame = findViewById(R.id.native_frame);
ViewBinder viewBinder = new ViewBinder.Builder(R.layout.view_mopub_ad_view)
.titleId(R.id.native_title)
.textId(R.id.native_text)
.mainImageId(R.id.native_main_image)
.iconImageId(R.id.native_icon_image)
.callToActionId(R.id.native_cta)
.privacyInformationIconImageId(R.id.native_privacy_information_icon_image)
.build();
ConsoliAds.Instance().addMopubNativeAd( sceneIndex , viewBinder );

After performing these steps, follow the step number 2, 3 and 4 from the above (multiple native ads) section.

Icon Ad

Icon ad comes in different sizes (Small, Medium, Large)
Login to your ConsoliAds portal and go to Apps->Mediation->(Your APP)->Placeholders & Ads
Add icon ad slot


Add the following xml in your required activity view:

<com.consoliads.sdk.iconads.IconAdView
android:id="@+id/consoli_icon_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content">

</com.consoliads.sdk.iconads.IconAdView>

Add the following line in your activity java file:

IconAdView iconAdView = findViewById(R.id.consoli_icon_view);

Get and show icon ad:

IconAdBase iconAdBase = (IconAdBase) ConsoliAds.Instance().getIconAdView(currentScene , MainActivity.this); If( iconAdBase != null ){ iconAdView.setIconAd(iconAdBase); }

Implementing Call Back Events

ConsoliAds provides the following callbacks for different events. Just make sure that your activity extends the abstract class
“ConsoliAdsListener” and override your required callback methods to receive event callbacks.

public ConsoliAdsListener() {
}
public void onInterstitialAdShownEvent() {
}
public void onInterstitialAdClickedEvent() {
}
public void onInterstitialAdClosedEvent() {
}
public void onVideoAdShownEvent() {
}
public void onVideoAdClickedEvent() {
}
public void onRewardedVideoAdShownEvent() {
}
public void onRewardedVideoAdCompletedEvent() {
}
public void onRewardedVideoAdClickEvent() {
}
public void onPopupAdShownEvent() {
}
public void onNativeAdLoadedEvent(AdNetworkName var1) {
}
public void onNativeAdLoadedEvent(AdNetworkName var1, int var2) {
}
public void onIconAdShownEvent() {
}
public void onIconAdFailedToShownEvent() {
}
public void onIconAdClosedEvent() {
}
public void onIconAdClickEvent() {
}
public void onNativeAdFailedToLoadEvent(AdNetworkName var1) {
}
public void onNativeAdFailedToLoadEvent(AdNetworkName var1, int var2) {
}
public abstract void onConsoliAdsInitializationSuccess();
public void onSuccessfulSyncUserResponseToWrapper(String var1) {
}

Configure Server

Configure server is a mandatory step. First, check for java support by typing the following command in command prompt (or terminal in mac).

java -version

Find “libConfigureServer.jar” in ConsoliAds-mediation package and place it in root directory of the project. Now open command prompt (or terminal in mac) and go to root directory of the project to run the following command.

java -jar libConfigureServer.jar userSignature AppPackage platform

Example:

java -jar libConfigureServer.jar 5d4b02b39dc419548ea8183e8d3ea170 com.seasonapps.myfitnessguide google

User Signature: A user identification code which is present in the personal info tab of your account.

 

ConsoliAds Mediation Sample App

You can download sample ConsoliAds project here
And you can find ConsoliAds sample application using list view for showing native ads inside list view in Android. You can also find it in documentation.

XML STUCTURE FOR NATIVE ADS

Admob

For Admob developer is required to only add this frame in layout and pass this reference in Admob configure method:

< FrameLayout
android:layout_margin="8dp"
android:layout_marginTop="8dp"
android:id="@+id/admob_native_frame"
android:layout_width="match_parent"
android:layout_height="wrap_content">

Facebook

For Facebook native ad following are the required elements:

<LinearLayout
android:visibility="gone"
android:id="@+id/ad_unit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/white"
android:orientation="vertical"
android:paddingLeft="10dp"
android:paddingRight="10dp">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingBottom="10dp"
android:paddingTop="10dp">

<com.facebook.ads.AdIconView
android:id="@+id/native_ad_icon"
android:layout_width="35dp"
android:layout_height="35dp">

<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingLeft="5dp"
android:paddingRight="5dp">

<TextView
android:id="@+id/native_ad_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:lines="1"
android:textColor="@android:color/black"
android:textSize="15sp" />

<TextView
android:id="@+id/native_ad_sponsored_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:lines="1"
android:textColor="@android:color/darker_gray"
android:textSize="12sp" />

<LinearLayout
android:id="@+id/ad_choices_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="end"
android:orientation="horizontal" />

</LinearLayout>
<com.facebook.ads.MediaView
android:id="@+id/native_ad_media"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center" />

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="5dp">

<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="3"
android:orientation="vertical">

<TextView
android:id="@+id/native_ad_social_context"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
android:lines="1"
android:textColor="@android:color/darker_gray"
android:textSize="12sp" />

<TextView
android:id="@+id/native_ad_body"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
android:gravity="center_vertical"
android:lines="2"
android:textColor="@android:color/black"
android:textSize="12sp" />
</LinearLayout>

<Button android:id="@+id/native_ad_call_to_action"
android:layout_width="100dp"
android:layout_height="30dp"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:background="#4286F4"
android:paddingLeft="3dp"
android:paddingRight="3dp"
android:textColor="@android:color/white"
android:textSize="12sp"
android:visibility="gone" />
</LinearLayout>

ConsoliAds

For ConsoliAds native ad following are the required elements:

<LinearLayout
android:visibility="gone"
android:layout_marginBottom="8dp"
android:id="@+id/native_container"
android:orientation="vertical"
android:background="#FFF"
android:padding="8dp"
android:layout_width="match_parent"
android:layout_height="wrap_content">

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">

<TextView
android:id="@+id/ad"
android:textStyle="bold"
android:textColor="#FFF"
android:background="#FAA845"
android:textSize="10sp"
android:padding="2dp"
android:text="Ad"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />

<TextView
android:layout_toRightOf="@+id/ad"
android:textStyle="bold"
android:textColor="#FAA845"
android:textSize="10sp"
android:padding="2dp"
android:text="Consoliads"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />

<com.consoliads.sdk.nativeads.AdChoices
android:id="@+id/native_adchoices_main"
android:layout_width="12dp"
android:layout_height="12dp"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true">

</com.consoliads.sdk.nativeads.AdChoices>

</RelativeLayout>

<LinearLayout
android:layout_margin="8dp"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">

<TextView
android:textSize="16sp"
android:id="@+id/tv_ad_title"
android:textStyle="bold"
android:textColor="@android:color/holo_blue_dark"
android:text="Drone Builder Kit"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />

<ImageView
android:id="@+id/iv_ad_image"
android:scaleType="fitXY"
android:layout_marginLeft="32dp"
android:layout_marginRight="32dp"
android:layout_marginTop="16dp"
android:layout_marginBottom="16dp"
android:layout_width="match_parent"
android:layout_height="150dp" />

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">

<TextView
android:id="@+id/tv_ad_sub_title"
android:textStyle="bold"
android:text="Circuit Scribe"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />

<TextView
android:layout_marginRight="8dp"
android:layout_alignParentLeft="true"
android:layout_alignLeft="@+id/native_action_button"
android:layout_below="@id/tv_ad_sub_title"
android:id="@+id/tv_ad_description"
android:textSize="10sp"
android:textStyle="bold"
android:text="Our new DIY Drone Builder Kit lets you build"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />

<com.consoliads.sdk.nativeads.ActionButton
android:layout_centerVertical="true"
android:id="@+id/native_action_button"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</com.consoliads.sdk.nativeads.ActionButton>
</RelativeLayout>

</LinearLayout>

AppLovin

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="320dp"
android:padding="4dp"
android:visibility="visible"
android:id="@+id/parent_container"
android:background="#FFF"
tools:context=".activities.MainActivity">

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerHorizontal="true"
android:id="@+id/relativeLayout">

<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="50dp"
android:gravity="center_vertical"
android:layout_alignParentTop="true"
android:id="@+id/linearLayout2"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true">

<ImageView
android:layout_width="50dp"
android:layout_height="50dp"
android:id="@+id/appIcon"
android:adjustViewBounds="true"
android:src="@drawable/logo" />

<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_gravity="left|center_vertical">

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Large Text"
android:id="@+id/appTitleTextView"
android:layout_gravity="left|center_vertical" />

<ImageView
android:layout_width="100dp"
android:layout_height="match_parent"
android:id="@+id/appRating"
android:maxWidth="50dp"
android:scaleType="fitCenter"
android:src="@drawable/applovin_star_sprite_0" />
</LinearLayout>

</LinearLayout>
<TextView
android:id="@+id/appDescriptionTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="App description"
android:gravity="left"
android:textAppearance="?android:attr/textAppearanceMedium"
android:paddingBottom="4dp"
android:layout_below="@+id/linearLayout2"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_marginTop="4dp" />

<FrameLayout
android:id="@+id/mediaViewPlaceholder"
android:layout_width="wrap_content"
android:layout_height="184dp"
android:layout_gravity="center"
android:background="@android:color/black"
android:layout_below="@+id/appDescriptionTextView"
android:layout_alignParentLeft="false"
android:layout_alignParentStart="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true">

</FrameLayout>
<Button
android:layout_marginTop="4dp"
android:textStyle="bold"
android:textColor="#FFF"
android:background="@android:color/holo_blue_light"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="CTA"
android:id="@+id/appDownloadButton"
android:enabled="true"
android:layout_below="@+id/mediaViewPlaceholder"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
</RelativeLayout>

</LinearLayout>

Mintegral

For Mintegral native ad following are the required elements:

<LinearLayout
android:orientation="vertical"
android:id="@+id/inmobi_ad_container"
android:layout_width="match_parent"
android:layout_height="300dp">

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">

<ImageView
android:id="@+id/inmobi_adIcon"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_centerVertical="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />

<TextView
android:id="@+id/inmobi_adSponsored"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_toEndOf="@id/inmobi_adIcon"
android:layout_toRightOf="@id/inmobi_adIcon"
android:layout_toStartOf="@id/inmobi_adSponsored"
android:layout_toLeftOf="@id/inmobi_adSponsored"
android:layout_centerVertical="true"
android:orientation="vertical">

<TextView
android:id="@+id/inmobi_adTitle"
android:layout_gravity="center_vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />

<RatingBar
android:id="@+id/inmobi_adRating"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />

</LinearLayout>

</RelativeLayout>

<FrameLayout
android:id="@+id/inmobi_adContent"
android:layout_width="match_parent"
android:layout_height="wrap_content" />

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">

<TextView
android:id="@+id/inmobi_adAction"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />

<TextView
android:id="@+id/inmobi_adDescription"
android:layout_toLeftOf="@id/inmobi_adAction"
android:layout_toStartOf="@id/inmobi_adAction"
android:layout_centerVertical="true"
android:maxLines="2"
android:ellipsize="marquee"
android:layout_width="match_parent"
android:layout_height="wrap_content" />

</RelativeLayout>

</LinearLayout>

Inmobi

For Inmobi native ad following are the required elements:

<LinearLayout
android:orientation="vertical"
android:id="@+id/inmobi_ad_container"
android:layout_width="match_parent"
android:layout_height="300dp">

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">

<ImageView
android:id="@+id/inmobi_adIcon"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_centerVertical="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />

<TextView
android:id="@+id/inmobi_adSponsored"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_toEndOf="@id/inmobi_adIcon"
android:layout_toRightOf="@id/inmobi_adIcon"
android:layout_toStartOf="@id/inmobi_adSponsored"
android:layout_toLeftOf="@id/inmobi_adSponsored"
android:layout_centerVertical="true"
android:orientation="vertical">

<TextView
android:id="@+id/inmobi_adTitle"
android:layout_gravity="center_vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />

<RatingBar
android:id="@+id/inmobi_adRating"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />

</LinearLayout>

</RelativeLayout>

<FrameLayout
android:id="@+id/inmobi_adContent"
android:layout_width="match_parent"
android:layout_height="wrap_content" />

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">

<TextView
android:id="@+id/inmobi_adAction"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />

<TextView
android:id="@+id/inmobi_adDescription"
android:layout_toLeftOf="@id/inmobi_adAction"
android:layout_toStartOf="@id/inmobi_adAction"
android:layout_centerVertical="true"
android:maxLines="2"
android:ellipsize="marquee"
android:layout_width="match_parent"
android:layout_height="wrap_content" />

</RelativeLayout>

</LinearLayout>

Leadbolt

For Leadbolt native ad following are the required elements:

<RelativeLayout
xmlns:tools="http://schemas.android.com/tools"
android:background="#000"
android:layout_width="match_parent"
android:layout_height="300dp"
android:id="@+id/native_ad_container">

<LinearLayout
android:layout_margin="3dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:orientation="vertical">

<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="50dp">

<ImageView
android:id="@+id/icon_image"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_gravity="center_vertical"/>

<LinearLayout
android:layout_toRightOf="@id/icon_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_gravity="center_vertical"
android:layout_marginLeft="5dp">

<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Title"
android:textColor="@android:color/white"/>

<TextView
android:id="@+id/description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Description"
android:textColor="@android:color/white"/>

</LinearLayout>

</LinearLayout>

<ImageView
android:layout_marginBottom="3dp"
android:layout_marginTop="3dp"
android:id="@+id/media_image"
android:layout_width="match_parent"
android:layout_height="180dp"
android:scaleType="fitXY"/>

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:orientation="horizontal" >

<Button
android:gravity="center"
android:textColor="#FFF"
android:textStyle="bold"
android:background="@android:color/holo_blue_light"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:id="@+id/action_button"
android:layout_width="120dp"
android:layout_height="wrap_content"/>

</RelativeLayout>

</LinearLayout>

</RelativeLayout>

Mobfox

For Mobfox native ad following are the required elements:

<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/res-auto"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/nativeLayout"
android:layout_width="match_parent"
android:layout_height="300dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
android:gravity="center"
ads:layout_constraintBottom_toBottomOf="parent"
ads:layout_constraintEnd_toEndOf="parent"
ads:layout_constraintStart_toStartOf="parent"
ads:layout_constraintTop_toTopOf="parent"
ads:layout_constraintVertical_bias="0.032">

<TextView
android:id="@+id/nativeheadline"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
ads:layout_constraintBottom_toBottomOf="parent"
ads:layout_constraintEnd_toEndOf="parent"
ads:layout_constraintHorizontal_bias="0.0"
ads:layout_constraintStart_toEndOf="@+id/nativeIcon"
ads:layout_constraintTop_toTopOf="parent"
ads:layout_constraintVertical_bias="0.0" />

<ImageView
android:id="@+id/nativeMainImg"
android:layout_width="218dp"
android:layout_height="100dp"
android:layout_centerInParent="true"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
ads:layout_constraintBottom_toBottomOf="parent"
ads:layout_constraintEnd_toEndOf="parent"
ads:layout_constraintHorizontal_bias="0.0"
ads:layout_constraintStart_toStartOf="parent"
ads:layout_constraintTop_toTopOf="parent" />

<ImageView
android:id="@+id/nativeIcon"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_below="@+id/nativeheadline"
android:layout_alignParentStart="true"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
android:adjustViewBounds="true"
android:maxWidth="300dp"
android:maxHeight="300dp"
android:scaleType="fitCenter"
ads:layout_constraintBottom_toBottomOf="parent"
ads:layout_constraintEnd_toEndOf="parent"
ads:layout_constraintHorizontal_bias="0.0"
ads:layout_constraintStart_toStartOf="parent"
ads:layout_constraintTop_toTopOf="parent"
ads:layout_constraintVertical_bias="0.0" />

<Button
android:id="@+id/nativecta"
android:layout_width="wrap_content"
android:layout_height="35dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
android:gravity="center"
android:textSize="10dp"
ads:layout_constraintBottom_toBottomOf="parent"
ads:layout_constraintEnd_toEndOf="parent"
ads:layout_constraintHorizontal_bias="1.0"
ads:layout_constraintStart_toStartOf="parent"
ads:layout_constraintTop_toTopOf="parent"
ads:layout_constraintVertical_bias="1.0" />

<TextView
android:id="@+id/nativedesc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
android:textSize="10dp"
ads:layout_constraintBottom_toBottomOf="parent"
ads:layout_constraintEnd_toEndOf="parent"
ads:layout_constraintHorizontal_bias="0.0"
ads:layout_constraintStart_toEndOf="@+id/nativeIcon"
ads:layout_constraintTop_toTopOf="parent"
ads:layout_constraintVertical_bias="0.142" />

</android.support.constraint.ConstraintLayout>

StartApp

For StartApp native ad following are the required elements:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:background="#000"
android:layout_width="match_parent"
android:layout_height="250dp"
android:id="@+id/st_native_ad_container"
tools:context=".activities.MainActivity" >

<LinearLayout
android:layout_margin="3dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:orientation="vertical">

<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="50dp">

<ImageView
android:id="@+id/st_icon_image"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_gravity="center_vertical"/>

<LinearLayout
android:layout_toRightOf="@id/icon_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_gravity="center_vertical"
android:layout_marginLeft="5dp">

<TextView
android:id="@+id/st_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Title"
android:textColor="@android:color/white"/>

<TextView
android:id="@+id/st_description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Description"
android:textColor="@android:color/white"/>

</LinearLayout>

</LinearLayout>

<ImageView
android:layout_marginBottom="3dp"
android:layout_marginTop="3dp"
android:id="@+id/st_media_image"
android:layout_width="match_parent"
android:layout_height="200dp"
android:scaleType="fitXY"/>

</LinearLayout>

</RelativeLayout>

ConsoliAds GitHub forum

If you are having any technical issues you can visit https://github.com/teamconsoliads/sampleapp-android to view known issues, share problems and suggestions.
Note: According to the Admob documentation if you are using play services version greater than 17.x then you have to make sure that you add your Admob appID inside AndroidManifest.xml file. Otherwise, your app will crash.

Was this article helpful?
Dislike 1
Views: 855