Get Started with Glispa Connect

Overview

Examples

Android

Overview

- Native Ads

List/Feed

Custom

- Standard IAB Formats

Banner

Interstitial

Video

- Others

GDPR

Troubleshooting

Admob Android Adapter

Mopub Android Adapter

DFP Android Adapter

iOS

Overview

- Native Ads

List/Feed

Custom

- Standard IAB Formats

Banner

Interstitial

Video

- Others

GDPR

Troubleshooting

- Adapters

Admob iOS Adapter

Mopub iOS Adapter

DFP iOS Adapter

API Documentation

Reporting API

Help

GDPR FAQ

General

Earnings

Payments and Accounting

Integration

Reporting

Legal and Privacy

Updates

SDK Deprecation Schedule

SDK Change Log

Android Change Log

iOS Change Log

Banner

Updated 6 days ago by Derek Lim

Overview

This tutorial helps you setup banner ads and receive your first ad from the Glispa Connect (formerly Avocarrot) Exchange.

Prerequisites

Create a  Banner unit from your app on Glispa Connect Dashboard 

Requirements & Dependencies

  • Android 4.0 (API Version 14) and up
  • support-annotations, v27.1.0
  • support-v4, v27.1.0
  • Recommended Google Play Services v12.0.1

We strongly recommend compiling your app using Google Play services, in order to use the Android Advertising IDinstead of the Device ID, as required by Google. Failing to correctly use the Android Advertising ID may result in your submission to the Play Store being rejected.

You must have a different adUnitId for every ad space placement in your app. If you use the same ID for multiple placements or the IDs from the testing/demo examples, reporting errors will occur and there will be no payout. Please ask your account manager for further details.

Setup SDK

The SDK is available via:
1. jCenter AAR (Recommended) 
2. Zipped AAR 

  1. Add the following rows in your app module build.gradle file:
     
    repositories {
                  maven { url 'https://maven.google.com'}
                  maven { url "https://s3.amazonaws.com/avocarrot-android-builds/dist/" }
              }
  2. Add the following dependencies:
    dependencies {
                ...
                compile 'com.avocarrot.sdk:mediation-sdk-banner:4.10.2'
                compile 'com.google.android.gms:play-services-ads:12.0.1'
              }
  3. Update AndroidManifest.xml
     
    <?xml version="1.0" encoding="utf-8"?>
              <manifest ... >
                 <!-- Required -->
                 <uses-permission android:name="android.permission.INTERNET" />
                 <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
                 <!-- Optional -->
                 <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
                 <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
                 <application ...>
                    <activity> ... </activity>
                    <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
                 </application>
              </manifest>
  1. Include the Local .aar Libraries

    You can find local aar files in our sample project under libraries here
    Save the aar files under app module’s libs folder (eg: <project>/<app>/libs) Then add the following rows in your app module build.gradle file:

    repositories {
                flatDir {
                  dirs 'libs'
                }
              }
              
  2. Include the following dependencies:

    dependencies {
                  compile(name: 'core', version:'4.10.2', ext: 'aar')
                  compile(name: 'mediation-sdk', version:'4.10.2', ext: 'aar')
                  compile(name: 'mediation-sdk-mraid', version:'4.10.2', ext: 'aar')
                  compile(name: 'mediation-sdk-banner', version:'4.10.2', ext: 'aar')
                  compile 'com.google.android.gms:play-services-ads:12.0.1'
              }
              
  3. Then add following rows in your app module proguard-rules.pro file:

    -keep class com.avocarrot.** { *; }
              -dontwarn com.avocarrot.**
              // To ensure GAID can be extract from Google play services
              -keep class com.google.android.gms.ads.identifier.AdvertisingIdClient$Info { *; }     
              
  4. Update AndroidManifest.xml

    <?xml version="1.0" encoding="utf-8"?>
              <manifest ... >
                 <!-- Required -->
                 <uses-permission android:name="android.permission.INTERNET" />
                 <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
                 <!-- Optional -->
                 <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
                 <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
                 <application ...>
                    <activity> ... </activity>
                    <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
                 </application>
              </manifest>
  • ACCESS_COARSE_LOCATION (recommended) – Grants the SDK permission to access approximate location based on cell tower.
  • ACCESS_FINE_LOCATION (recommended) – Grants the SDK permission to access a more accurate location based on GPS.
    Although not technically required, the LOCATION permissions make it possible for the SDK to send location-based data to advertisers. Sending better location data generally leads to better monetization.
  • WRITE_EXTERNAL_STORAGE (optional) – Allows the SDK to cache all ad assets (creatives, custom frames, etc.) in external memory. This can maximize performance by ensuring immediate delivery of ads and minimize network traffic used by the SDK by keeping cached ad assets available even after the user closes the app.
  • READ_PHONE_STATE (recommended) – Allows the SDK to handle calls interrupting video playback during videos.
 When using SDK as a library project, you shouldn’t need to worry about merging AndroidManifest.xml changes or Proguard settings. If you run into problems, make sure manifestmerger.enabled is set to true in project.properties Please see the Android documentation here.
As the General Data Protection Regulation (GDPR) takes effect on May 25th, 2018 it is required to use the latest GDPR ready SDK and pass your users’ consent as seen here, in order to be up-to-date and compliant.

Setup Banner Ads

All SDK method calls should be done from the main thread (Main thread, UI thread).
  1. Add a banner to layout file, e.g.:
    <FrameLayout
                  android:id="@+id/ad_view"    
                  android:layout_width="320dp"
                  android:layout_height="50dp"
                  android:background="@android:color/white"/>

    It is advisable to make the banner size in the layout the same as the required one (see below). Otherwise, the banner might be displayed incorrectly.
  2. Add the following code to your activity:
    FrameLayout adView = (FrameLayout) findViewById(R.id.ad_view);
              BannerAd bannerAd = BannerAdPool.load(this, "YOUR_BANNER_AD_UNIT_ID", adView, BannerSize.BANNER_SIZE_320x50, bannerAdListener);
              


    Banners320*50are served by default. Available sizes:

    • 320×50
    • 300x250 (MREC)
    • 728×90
    • 300x250
    • 468x60
    • 160x600
    • 300x50


    Banner Auto-update
    You can switch the banner auto-update function on or off; to do this, call setAutorefreshEnabled()

    bannerAd.setAutorefreshEnabled(false);

    By default, auto-update is switched on. The auto-update period is set up via the admin panel.If you need to reload Banner manually, call

    bannerAd.reloadAd();
  3. Activity lifecycle events handling

    onPause()onResume()andonDestroy()methods should be called depending on the activity lifecycle events. Example:

    @Override
              protected void onPause() {
                  super.onPause();
                  bannerAd.onActivityPaused();
              }
              @Override
              protected void onResume() {
                  super.onResume();
                  bannerAd.onActivityResumed();
              }
              @Override
              protected void onDestroy() {
                  super.onDestroy();
                  bannerAd.onActivityDestroyed();
              }
  4. Congratulations! Compile and Run your project. You can now further customize your banner ads.

Advanced Customization

Go Live!

  1. Remove sandbox If you have received a sample ad then simply disable the Sandbox mode by including the following instruction in your code:
    Avocarrot.setTestMode(false);
    You should disable Sandbox mode ONLY when you are done with the integration and you are ready to publish your app. It is against Glispa Connect's policies to use live ads during development, and doing so could get your Glispa Connect account banned.
  2. Publish your app. You are now ready to upload your app and start making money! If you have submitted your app in the Google Play/ Apple Store and you can see live ads, then you have nothing to worry about. Just wait until the impressions threshold has been reached and the app will be shown as live in your dashboard as well.
  3. Update payment details. Login to your account and update your payment settings.

Was this article useful?