Get Started with Avocarrot

Overview

Examples

Android

Overview

- Avocarrot Exchange SDK

Setup Exchange SDK

Stream

Native Assets

Exchange Troubleshooting

- Avocarrot Mediation SDK

Setup Mediation

Stream Ads Mediation

Native ads Mediation

Native Assets Mediation

Banner Mediation

Interstitial Mediation

Video Mediation

Supported Networks & Ad Types

Mediation Troubleshooting

iOS

Overview

- Avocarrot Exchange SDK

Setup SDK

Stream

Native Assets

Exchange Troubleshooting

- Avocarrot Mediation

Getting Started With Mediation

Stream Ads Mediation

Native Ads Mediation

Banner Ads Mediation

Interstitial Ads Mediation

Video Ads Mediation

Supported Networks & Ad Types

Mediation Troubleshooting

API Documentation

Reporting API

Help

FAQ

Updates

SDK Change Log

Android Change Log

iOS Change Log

Android SDK Migration Guide

Updated 2 months ago ​by Chris

Overview

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

You can have a look at the rest documentation here.

Terminology Changes

Old version (v3.x)New version (v4.x)
Feed/List/InstreamStream
AvocarrotInstreamStreamAdBaseAdapter
AvocarrotInstreamRecyclerViewStreamAdRecyclerAdapter
NaturalPause / AvocarrotInterstitialInterstitialAd
AvocarrotCustomNativeAssetsAd
CustomModelNativeAssets

Install Avocarrot SDK

Download new Avocarrot Jar

Or update your build.gradle to use the latest Avocarrot SDK

dependencies {
...
    compile('com.avocarrot:android-sdk:4.0.+')
...
}

You can find a fully working example in our open source demo app project here


Android Manifest

Update package name from com.avocarrot.androidsdk to com.avocarrot.sdk

Old version (v3.x)New version (v4.x)
<activity android:name="com.avocarrot.androidsdk.VideoActivity" /><activity android:name="com.avocarrot.sdk.VideoActivity" />
<activity android:name="com.avocarrot.androidsdk.RedirectActivity" /><activity android:name="com.avocarrot.sdk.RedirectActivity" />

Stream

Old version (v3.x) New version  (v4.x)
AvocarrotInstream avocarrotInstream = 
   new AvocarrotInstream(
      <yourAdapter>,
      this, /* Context */
      "<your API Key>",
      "<your Ad unit id (Placement Key)>"
   );
avocarrotInstream.setLogger(true, "ALL");
avocarrotInstream.setSandbox(true);
<yourListView>.setAdapter(avocarrotInstream);
<yourListView>.setAdapter(
   Avocarrot.build(
      this /* Context */,
      new StreamAdBaseAdapter.Configuration.Builder()
         .setAdapter(<yourAdapter>)
         .setApiKey("<your API Key>")
         .setAdUnitId("<your Ad unit id>")
         .setLogLevel(Level.DEBUG)
         .setSandbox(true)
   )
);
AvocarrotInstreamRecyclerView avocarrotInstreamRecyclerView = 
new AvocarrotInstreamRecyclerView(
   <yourAdapter>,
   this, /* Context */
   "<your API Key>",
   "<your Ad unit id (Placement Key)>"
 );
avocarrotInstreamRecyclerView.setLogger(true, "ALL");
avocarrotInstreamRecyclerView.setSandbox(true);
<yourRecyclerView>.setLayoutManager( new LinearLayoutManager(this) );
<yourRecyclerView>.setAdapter(avocarrotInstreamRecyclerView);
<yourRecyclerView>.setLayoutManager( new LinearLayoutManager(this) );
<yourRecyclerView>.setAdapter(
   Avocarrot.build(
      this /* Context */,
      new StreamAdRecyclerAdapter.Configuration.Builder()
         .setAdapter(<yourAdapter>)
         .setApiKey("<your API Key>")
         .setAdUnitId("<your Ad unit id>")
         .setLogLevel(Level.DEBUG)
         .setSandbox(true)
   )
);

Interstitial

Old version (v3.x)New version (v4.x)
AvocarrotInterstitial avocarrotInterstitial =   
    new AvocarrotInterstitial(      
        this, /* Activity */      
        "<your API Key>",      
        "<your Ad unit id (Placement Key)>"   
    ); 
avocarrotInterstitial.setLogger(true, "ALL"); 
avocarrotInterstitial.setSandbox(true); 
avocarrotInterstitial.loadAndShowAd();
Avocarrot.build(   
    this /* Activity */,   
    new InterstitialAd.Configuration.Builder()
      .setApiKey("<your API Key>")      
      .setAdUnitId("<your Ad unit id>")
      .setLogLevel(Level.DEBUG)
      .setSandbox(true)
).loadAndShowAd();

Native Assets

Old version (v3.x)New version (v4.x)
final AvocarrotCustom avocarrotCustom =
      new AvocarrotCustom(
         this, /* Activity */
         "<your API Key>",
         "<your Ad unit id (Placement Key)>"
      );
avocarrotCustom.setLogger(true, "ALL");
avocarrotCustom.setSandbox(true);
avocarrotCustom.setListener(
   new AvocarrotCustomListener() {
      @Override
      public void onAdLoaded(List<CustomModel> ads) {
         super.onAdLoaded(ads);
         if ((ads==null) || (ads.size()<1)){
            return;
         }
         final CustomModel ad = ads.get(0);
         ViewGroup container = ...;
         TextView title = ...;
         ImageView imageView = ...;
         ImageView iconView = ...;
         Button button = ...;
         com.avocarrot.androidsdk.VideoView videoView = ...;
         com.avocarrot.androidsdk.ui.AdChoicesView adChoicesView = ...;
         
         title.setText(ad.getTitle());
         button.setText(ad.getCTAText());
         avocarrotCustom.loadIcon(ad, iconView);
         avocarrotCustom.loadImage(ad, imageView);
         avocarrotCustom.loadMedia(ad, imageView, videoView);
         avocarrotCustom.bindView(ad, container, adChoicesView);
         button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
               avocarrotCustom.handleClick(ad);
            }
         });
      }
  });
  avocarrotCustom.loadAd();
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();

Mopub Adapter

You can migrate Mopub  Avocarrot Adapter using these links :

1) Update the Avocarrot Adapter

Fullscreen Ad
https://github.com/Avocarrot/android-adapters/blob/master/avocarrotadapter/src/main/java/com/mopub/mobileads/AvocarrotInterstitialMopub.java

Native Ad
https://github.com/Avocarrot/android-adapters/blob/master/avocarrotadapter/src/main/java/com/mopub/nativeads/AvocarrotNativeMopub.java 

2) Add AdUnitId in CustomEventClassData of the Mopub Dashboard :

Old version (v3.x)New version (v4.x)
{
   "apiKey":"<Avocarrot ApiKey>",
   "placementKey":"<Avocarrot AdUnitId>"
}
{
   "apiKey":"<Avocarrot ApiKey>",
   "placementKey":"<Avocarrot AdUnitId>",
   "adUnitId":"<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?