Get Started with Avocarrot

Overview

Examples

Android

Overview

Getting Started

- Integrating Ads

Stream

Native Assets

Banner

Interstitial

Video

- Others

Troubleshooting

- Adapters

Admob Android Adapter

Mopub Android Adapter

iOS

Overview

Getting Started

- Integrating Ads

Stream

Native Assets

Banner

Interstitial

Video

- Others

Troubleshooting

- Adapters

Admob iOS Adapter

Mopub iOS Adapter

API Documentation

Reporting API

Help

Supported Networks & Ad Types

General

Earnings

Payments and Accounting

Integration

Reporting

Mediation Network Optimization

Legal and Privacy

Updates

SDK Change Log

Android Change Log

iOS Change Log

Getting Started

Updated 2 days ago ​by Derek Lim

Overview

This tutorial helps you install the Avocarrot SDK in your Android app.

You need an Avocarrot account to complete the tutorial. Create an account

Requirements and Dependencies

  • Android 4.0 (API Version 14) and up
  • support-annotations, v26.1.0
  • support-v4, v26.1.0
  • Recommended Google Play Services v11.4.2

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.
Please note that if you are an existing Avocarrot publisher and migrating from Avocarrot SDK v3.x to Avocarrot v4.x you should consult our migration guide here.
Please note that if you are an existing Avocarrot publisher and migrating from Avocarrot SDK v4.0 to Avocarrot v4.x you should consult our migration guide here.

Install 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. To install exchange  include the following:


    dependencies {
      ...
      compile 'com.avocarrot.sdk:mediation-sdk-nativead:4.7.1'
      compile 'com.google.android.gms:play-services-ads:11.4.2'
     }

    To install mediation include the following:

    dependencies {
      ...
      compile 'com.avocarrot.sdk:mediation-sdk-banner:4.7.1'
      compile 'com.avocarrot.sdk:mediation-sdk-interstitial:4.7.1'
      compile 'com.avocarrot.sdk:mediation-sdk-video:4.7.1'
      compile 'com.avocarrot.sdk:mediation-sdk-nativead:4.7.1'
      //3rd party SDKs if you need. Don't need to corresponding mediation-sdk module
      compile 'com.avocarrot.sdk:mediation-admob-banner:4.7.1'
      compile 'com.avocarrot.sdk:mediation-admob-interstitial:4.7.1'
      compile 'com.avocarrot.sdk:mediation-admob-nativead:4.7.1'
      compile 'com.avocarrot.sdk:mediation-applovin-interstitial:4.7.1'
      compile 'com.avocarrot.sdk:mediation-applovin-nativead:4.7.1'
      compile 'com.avocarrot.sdk:mediation-chartboost-interstitial:4.7.1'
      compile 'com.avocarrot.sdk:mediation-facebook-banner:4.7.1'
      compile 'com.avocarrot.sdk:mediation-facebook-interstitial:4.7.1'
      compile 'com.avocarrot.sdk:mediation-facebook-nativead:4.7.1'
      compile 'com.avocarrot.sdk:mediation-inlocomedia-banner:4.7.1'
      compile 'com.avocarrot.sdk:mediation-inlocomedia-interstitial:4.7.1'
      compile 'com.avocarrot.sdk:mediation-inlocomedia-nativead:4.7.1'
      compile 'com.avocarrot.sdk:mediation-mopub-banner:4.7.1'
      compile 'com.avocarrot.sdk:mediation-mopub-interstitial:4.7.1'
      compile 'com.avocarrot.sdk:mediation-mopub-nativead:4.7.1'
      compile 'com.avocarrot.sdk:mediation-nativex-interstitial:4.7.1'
      compile 'com.avocarrot.sdk:mediation-nativex-video:4.7.1'
      compile 'com.avocarrot.sdk:mediation-unityads-video:4.7.1'
      compile 'com.avocarrot.sdk:mediation-vungle-video:4.7.1'
      compile 'com.google.android.gms:play-services-ads:11.4.2'
    }

    You can also find the latest jar and changes of the SDK in the Android SDK Changelog.

  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. To install exchange  include the following:

    dependencies {
        compile(name: 'core', version:'4.7.1', ext: 'aar')
        compile(name: 'mediation-sdk', version:'4.7.1', ext: 'aar')
        compile(name: 'mediation-sdk-native-assets', version:'4.7.1', ext: 'aar')
        compile(name: 'mediation-sdk-nativead', version:'4.7.1', ext: 'aar')
        compile 'com.google.android.gms:play-services-ads:11.4.2'
    }
        

    To install mediation include the following:

    dependencies {
      compile(name: 'core', version:'4.7.1', ext: 'aar')
      compile(name: 'mediation-sdk', version:'4.7.1', ext: 'aar')
      
      //To use Native Assets only 
      compile(name: 'mediation-sdk-native-assets', version:'4.7.1', ext: 'aar')
      
      //To use Banners and Interstitials
      compile(name: 'mediation-sdk-mraid', version:'4.7.1', ext: 'aar')
      compile(name: 'mediation-sdk-banner', version:'4.7.1', ext: 'aar')
      compile(name: 'mediation-sdk-interstitial', version:'4.7.1', ext: 'aar')
      
      //To use Video and Native Ads
      compile(name: 'mediation-sdk-vast', version:'4.7.1', ext: 'aar')
      compile(name: 'mediation-sdk-video', version:'4.7.1', ext: 'aar')
      compile(name: 'mediation-sdk-nativead', version:'4.7.1', ext: 'aar')
      
      //3rd party SDKs
      compile(name: 'mediation-admob', version:'4.7.1', ext: 'aar')
      compile(name: 'mediation-admob-banner', version:'4.7.1', ext: 'aar')
      compile(name: 'mediation-admob-interstitial', version:'4.7.1', ext: 'aar')
      compile(name: 'mediation-admob-nativead', version:'4.7.1', ext: 'aar')
      compile(name: 'mediation-applovin', version:'4.7.1', ext: 'aar')
      compile(name: 'mediation-applovin-interstitial', version:'4.7.1', ext: 'aar')
      compile(name: 'mediation-applovin-nativead', version:'4.7.1', ext: 'aar')
      compile(name: 'mediation-chartboost', version:'4.7.1', ext: 'aar')
      compile(name: 'mediation-chartboost-interstitial', version:'4.7.1', ext: 'aar')
      compile(name: 'mediation-facebook', version:'4.7.1', ext: 'aar')
      compile(name: 'mediation-facebook-banner', version:'4.7.1', ext: 'aar')
      compile(name: 'mediation-facebook-interstitial', version:'4.7.1', ext: 'aar')
      compile(name: 'mediation-facebook-nativead', version:'4.7.1', ext: 'aar')
      compile(name: 'mediation-inlocomedia', version:'4.7.1', ext: 'aar')
      compile(name: 'mediation-inlocomedia-banner', version:'4.7.1', ext: 'aar')
      compile(name: 'mediation-inlocomedia-interstitial', version:'4.7.1', ext: 'aar')
      compile(name: 'mediation-inlocomedia-nativead', version:'4.7.1', ext: 'aar')
      compile(name: 'mediation-mopub', version:'4.7.1', ext: 'aar')
      compile(name: 'mediation-mopub-banner', version:'4.7.1', ext: 'aar')
      compile(name: 'mediation-mopub-interstitial', version:'4.7.1', ext: 'aar')
      compile(name: 'mediation-mopub-nativead', version:'4.7.1', ext: 'aar')
      compile(name: 'mediation-nativex', version:'4.7.1', ext: 'aar')
      compile(name: 'mediation-nativex-interstitial', version:'4.7.1', ext: 'aar')
      compile(name: 'mediation-nativex-video', version:'4.7.1', ext: 'aar')
      compile(name: 'mediation-unityads', version:'4.7.1', ext: 'aar')
      compile(name: 'mediation-unityads-video', version:'4.7.1', ext: 'aar'
      compile(name: 'mediation-vungle', version:'4.7.1', ext: 'aar'))
      compile(name: 'mediation-vungle-video', version:'4.7.1', ext: 'aar')
      compile 'com.google.android.gms:play-services-ads:11.4.2'
      compile 'com.facebook.android:audience-network-sdk:4.26.0'
      compile('com.mopub:mopub-sdk-banner:4.18.0@aar') {
        transitive = true
      }
      compile('com.mopub:mopub-sdk-interstitial:4.18.0@aar') {
          transitive = true
      }
      compile('com.mopub:mopub-sdk-native-static:4.16.0@aar') {
            transitive = true
      }
      compile 'com.inlocomedia.android:android-sdk:3.3.2'
    }
    
  3. Then add following rows in your app module proguard-rules.pro file:

    -keep class com.avocarrot.** { *; }
    -dontwarn com.avocarrot.**     
    
  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.
If you’re already integrated with a demand buyer,  It is not mandatory to remove all SDKs, but we would recommend it in order to ensure a seamless and coherent integration with Avocarrot.
 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.

Next Steps

Choose an ad format

You're ready to implement an ad. Avocarrot Exchange offers a number of native ad formats, so you can choose the one that best fits your app's user experience.


Was this article useful?