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
  • AndroidX migrated application (starting from 7.7.0 Smart Instream SDK version)) .

Installation via Gradle

To import the Smart Instream SDK into your Android project, here are the steps to follow:


  • In the main build.gradle of your project, you must declare the repository where the Smart Instream SDK is hosted.
    If you intend to support Huawei devices that do not feature Google services anymore (needed for Advertising Id retrieval), you also need to declare the Huawei support libraries repository:
    allprojects {
    	repositories {
    		google()
    		jcenter()
    
    		// add the Smart repository
    		maven { url 'https://packagecloud.io/smartadserver/android/maven2' }
    
    		// Optional: Huawei services dependencies repository
    		maven { url 'http://developer.huawei.com/repo/' }
    
    		// …
    	}
    }
  • In the dependencies section of your application module build.gradle file, declare the Smart Instream SDK artifact dependency and the optional Huawei support library:
    dependencies {
    	// …
    
    	// Add Smart Instream SDK
    	implementation 'com.smartadserver.android:smart-instream-sdk:7.13.0'
    
    	// Optional : add Smart support library for Huawei devices
    	implementation 'com.smartadserver.android:smart-core-sdk-huawei-support:1.0.0'
    
    }

    All dependencies needed by the Smart Instream SDK will be automatically imported by Gradle.

  • In the android section of your application module build.gradle file, add the Java 8 compile options needed by some imported libraries:
    android {
        // …
    
        compileOptions {
            targetCompatibility = JavaVersion.VERSION_1_8
            sourceCompatibility = JavaVersion.VERSION_1_8
        }
    }
  • You can now proceed with the integration of your ads by following the integration guide.