Getting started on Android

This page explains how to install the Smart Instream SDK into an Android application. This is the first step to complete before delivering instream ads in your video content.

  1. Prerequisites
  2. Installation using Gradle

Prerequisites

There are some prerequisites to use the instream SDK:

  • You need to use Android Studio 3.0 or higher
  • For phone apps, you need to target at least Android 4.4 (API level 19) or higher
  • For TV apps, you need to target at least Android 5.0 (API level 21) or higher

Installation using Gradle

To import the Smart Instream SDK into your Android project, you simply have to declare it using Gradle.


  • In the main build.gradle of your project, you must declare the Smart AdServer repository:
    allprojects {
    	repositories {
    		google()
    		jcenter()
    
    		// add the Smart AdServer repository
    		maven { url 'https://packagecloud.io/smartadserver/android/maven2' }
    
    		// …
    	}
    }
    
  • In the build.gradle corresponding to your application module, you can now import the Smart Instream SDK by declaring it in the dependencies section.

    Note that the Smart Instream SDK requires the Smart Core SDK. The Core SDK must always have a version at least equals to the Instream SDK (or higher, as long as they have the same major version). It also requires other libraries/framework as listed below

    dependencies {
    	// …
    
    	// add Smart SDK dependencies
    	implementation 'com.smartadserver.android:smart-core-sdk:1.1.0@aar'
    	implementation 'com.smartadserver.android:smart-instream-sdk:1.1.0@aar'
    
    	// add dependencies required by Smart SDK
    	implementation 'com.google.android.exoplayer:exoplayer:2.6.0'
    	implementation 'com.squareup.okhttp3:okhttp:3.6.0'
    
    	implementation 'com.google.android.gms:play-services-ads:+'
    	implementation 'com.google.android.gms:play-services-location:+'
    }
    

    If you do not already import any of the required depencies (which leaves you the choice of the exact version you want to import), you can also use the transitive flag that will infer all needed dependencies

    dependencies {
    	// …
    
    	// add Smart instream SDK dependency : all needed dependencies are automatically downloaded
    	implementation ('com.smartadserver.android:smart-instream-sdk:1.1.0@aar') {transitive = true}
    
    }
    
  • You can now proceed with the integration of your ads by following the integration guide.