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

Migrate from 4.0.x to Android SDK 4.5.x

Updated 1 year ago by Nikos Tsiougkos

Overview

This guide will help you migrate from Avocarrot Android SDK  v4.0.x to Avocarrot Android SDK v4.5.x. This concerns only existing Avocarrot publishers that are currently using SDK v4.0.x.

Terminology Changes

Old version (v4.0.x)New version (v4.5.x)
Sandbox
Test mode

Install Avocarrot SDK

Update your build.gradle to use the latest Avocarrot SDK

          repositories {
              maven { url "https://s3.amazonaws.com/avocarrot-android-builds/dist/" }
          }
          dependencies {
            ...
            compile 'com.avocarrot.sdk:mediation-sdk-nativead:4.5.0'
            compile 'com.google.android.gms:play-services-ads:11.0.4'
          }
Old version (v4.0.x)New version  (v4.5.x)
          <yourListView>.setAdapter(
             Avocarrot.build(
                this /* Context */,
                new StreamAdBaseAdapter.Configuration.Builder()
                   .setAdapter(<yourAdapter>)
                   .setApiKey(<your api key>)
                   .setAdUnitId(<your adUnitId)
                   .setLogLevel(Level.DEBUG)
                   .setSandbox(true)
             )
          );
          Avocarrot.setTestMode(true); // enable test ads
          Avocarrot.setDebugMode(true); // enable logger
          StreamAdBaseAdapter adAdapter = 
             new StreamAdBaseAdapter.Builder()
                 .setAdapter(<yourAdapter>)
                 .setAdUnitId(<your adUnitId>)
                 .setViewBuilder(DynamicNativeAdView.BUILDER)
                 .build(this /* Context */ );
          <yourListView>.setAdapter(adAdapter);
          adAdapter.loadAd();
          
          <yourRecyclerView>.setLayoutManager( new LinearLayoutManager(this) );
          <yourRecyclerView>.setAdapter(
             Avocarrot.build(
                this /* Context */,
                new StreamAdRecyclerAdapter.Configuration.Builder()
                   .setAdapter(<yourAdapter>)
                   .setApiKey(<your API Key>)
                   .setAdUnitId(<your adUnitId>)
                   .setLogLevel(Level.DEBUG)
                   .setSandbox(true)
             )
          );
          <yourRecyclerView>.setLayoutManager( new LinearLayoutManager(this) );
          Avocarrot.setTestMode(true); // enable test ads
          Avocarrot.setDebugMode(true); // enable logger
          StreamAdRecyclerAdapter adAdapter = 
             new StreamAdRecyclerAdapter.Builder()
                 .setAdapter(<yourAdapter>)
                 .setAdUnitId(<your adUnitId>)
                 .setViewBuilder(DynamicNativeAdView.BUILDER)
                 .build(this /* Context */ );
          <yourRecyclerView>.setAdapter(adAdapter);
          adAdapter.loadAd();

Interstitial

Old version (v4.0.x)New version (v4.5.x)
          Avocarrot.build(   
              this /* Activity */,   
              new InterstitialAd.Configuration.Builder()
                .setApiKey("<your API Key>")      
                .setAdUnitId("<your Ad unit id>")
                .setLogLevel(Level.DEBUG)
                .setSandbox(true)
          ).loadAndShowAd();
          Avocarrot.setTestMode(true); // enable test ads
          Avocarrot.setDebugMode(true); // enable logger
          NativeAdPool
             .load(this /* Activity */,
                   <your adUnitId>,
                   FullscreenNativeAdView.BUILDER,
                   null,
                   new NativeAdCallback() {
                      @Override
                      public void onAdLoaded(@NonNull NativeAd ad) {
                          ad.renderAdView();
                      }
                      @Override
                      public void onAdFailed(@NonNull NativeAd ad, 
                                             @NonNull ResponseStatus responseStatus) {}
                      @Override
                      public void onAdOpened(@NonNull NativeAd ad) {}
                      @Override
                      public void onAdClicked(@NonNull NativeAd ad) {}
                      @Override
                      public void onAdClosed(@NonNull NativeAd ad) {}
                      @Override
                      public void onAdCompleted(@NonNull NativeAd ad) {}
                  }
              )
             .reloadAd();

Native Assets

Old version (v4.0.x)New version (v4.x)
              
          Avocarrot.build(
             this /* Activity */,
             new NativeAssetsAd.Configuration.Builder()
                .setApiKey(<your API Key>)
                .setAdUnitId(<your Ad unit id>)
                .setLogLevel(Level.DEBUG)
                .setSandbox(true)
                .setCallback(new NativeAssetsAdCallback() {
                   @Override
                   public void onAdLoaded(@NonNull final NativeAssetsAd nativeAssetsAd, @NonNull final List<NativeAssets> ads) {
                      super.onAdLoaded(nativeAssetsAd, ads);
                      if (ads.size() == 0) {
                         return;
                      }
                      final NativeAssets ad = ads.get(0);
                      View adContainer = ...
                      TextView title = ...
                      TextView text = ...
                      Button callTo_Action = ...
                      ImageView icon = ...
                      RelativeLayout mediaContainer ...
                      ImageView adChoices = ...
                
                      AdLayout adLayout = 
                         new AdLayout.BuilderWithView(adContainer)
                             .setTitle(title)
                             .setText(text)
                             .setCallToAction(callTo_Action)
                             .setIcon(icon)
                             .setMediaContainer(mediaContainer)
                             .setAdChoices(adChoices)
                             .addClickableView(title)
                             .addClickableView(callTo_Action)
                             .build();
                
                      nativeAssetsAd.bindView(adLayout, ad);
                   }
             })
          ).loadAd();
          Avocarrot.setTestMode(true); // enable test ads
          Avocarrot.setDebugMode(true); // enable logger
          final NativeAssetsConfig.Builder config = 
              new NativeAssetsConfig.Builder()
                  .prefetchIcon(true)
                  .prefetchImage(true)
                  .prefetchAdChoiceIcon(true);
          NativeAssetsAdCallback nativeAssetsAdCallback = new NativeAssetsAdCallback() {
              @Override
              public void onAdLoaded(@NonNull NativeAssetsAd nativeAssetsAd, @NonNull NativeAssets nativeAssets) {
                  final View adContainer = ...
                  final List clickableViews = new ArrayList<>();
                  final TextView titleView = ...
                  final TextView bodyView = ...
                  final ImageView iconView = ...
                  final ImageView imageView = ...
                  final TextView ctaView = ...
                  final ImageView adChoiceImageView = ...
                  final TextView adChoiceTextView = ...
                  if (titleView != null) {
                      titleView.setText(nativeAssets.getTitle());
                      clickableViews.add(titleView);
                  }
                  if (bodyView != null) {
                      bodyView.setText(nativeAssets.getText());
                  }
                  if (iconView != null) {
                      iconView.setImageDrawable(nativeAssets.getIcon().getDrawable());
                      clickableViews.add(iconView);
                  }
                  if (imageView != null) {
                      imageView.setImageDrawable(nativeAssets.getImage().getDrawable());
                      clickableViews.add(imageView);
                  }
                  if (ctaView != null) {
                      ctaView.setText(nativeAssets.getCallToAction());
                      clickableViews.add(ctaView);
                  }
                  final AdChoice adChoice = nativeAssets.getAdChoice();
                  if (adChoice != null) {
                      if (adChoiceImageView != null) {
                          adChoiceImageView.setImageDrawable(adChoice.getIcon().getDrawable());
                          nativeAssetsAd.registerAdChoiceViewForClick(adChoiceImageView);
                      }
                      if (adChoiceTextView != null) {
                          adChoiceTextView.setText(adChoice.getIconCaption());
                          nativeAssetsAd.registerAdChoiceViewForClick(adChoiceTextView);
                      }
                  } else {
                      adChoiceImageView.setImageDrawable(null);
                      adChoiceTextView.setText(null);
                  }
                  nativeAssetsAd.registerViewsForClick(clickableViews);
                  nativeAssetsAd.registerViewForImpression(adContainer);
              }
              @Override
              public void onAdFailed(@NonNull NativeAssetsAd nativeAssetsAd, @NonNull ResponseStatus responseStatus) {}
              @Override
              public void onAdOpened(@NonNull NativeAssetsAd nativeAssetsAd) {}
              @Override
              public void onAdClicked(@NonNull NativeAssetsAd nativeAssetsAd) {}
          };
          NativeAssetsAdPool
                  .load(this, <your adUnitId>, config, nativeAssetsAdCallback)
                  .reloadAd();

Mopub Adapter

You can migrate Mopub  Avocarrot Adapter using these links :

1) Update the Avocarrot Adapter

2) Add AdUnitId in CustomEventClassData of the Mopub Dashboard :

Old version (v4.0.x)New version (v4.x)
          {
             "apiKey":"<Avocarrot ApiKey>",
             "placementKey":"<Avocarrot AdUnitId>",
             "adUnitId":"<Avocarrot adUnitId>"
          }
          {
              "adUnit":"<Avocarrot AdUnitID>"
          }


If you encounter any issues during the migration or you need further assistance please contact us at Support or through your dashboard chat.


Was this article useful?