Getting Started

Overview

The Android SDK 2.0 enables mobile app developers to seamlessly integrate ad units into their applications and monetize their user base. The SDK is lightweight, easy to integrate, and provides robust tools for controlling and tracking ad performance.

Supported ad units:

  • Banner (standard and smart resizing)

More ad formats will be added in future releases.



Getting Started

Prerequisites

Before integrating the new Android SDK 2.0, ensure the following:

  • Minimum Android SDK version: 24 (Android 7.0 Nougat)
  • Gradle Plugin: 7.0.0 or higher
  • Kotlin Compatibility: Kotlin 1.5 or higher (if using Kotlin)

Required Permissions

Add the following permission to your AndroidManifest.xml:

This permission is required to fetch and serve ads over the network.



Installation

To add the Android SDK 2.0 to your Android project, follow these steps:

Step 1: Add the Appnext Maven repository

In your project-level build.gradle (or settings.gradle in newer projects), include:

allprojects {  
    repositories {  
        maven {  
            url "<http://dl.appnext.com/">  
            allowInsecureProtocol = true  
        }  
    }  
}

⚠️

Note:

Since the repository uses HTTP, allowInsecureProtocol = true is required.


Step 2: Add the SDK dependency

In your app-level build.gradle file:

dependencies {  
    implementation("com.appnext.sdk:appnext-sdk:3.0.0.9") // Use latest version  
}

📌

The latest stable version is listed in the SDK Version History section.


Step 3: Sync your project

After updating your Gradle files, click "Sync Now" in Android Studio to apply the changes.



Initialization

Before loading ads, you must initialize the Android SDK 2.0. It is recommended to do this once in your Application class or in the onCreate method of your main Activity.

Example – Initialization in Application class:

class MyApp : Application() {
    override fun onCreate() {
        super.onCreate()
        AppnextSDK.getInstance().initialize(this.applicationContext)
    }
}

Example – Initialization in MainActivity:

class MainActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        AppnextSDK.getInstance().initialize(applicationContext)
    }
}

⚠️

Important

Call initialize() before loading any ad units.


GDPR & User Consent

To comply with data privacy regulations such as GDPR, developers can optionally set the user's consent status using the following method:

AppnextSDK.getInstance().setConsent(true)  // User has given consent  
AppnextSDK.getInstance().setConsent(false) // User has opted out
  • true – User has provided consent and GAID may be used.
  • false – User has not provided consent; GAID will not be sent.

📝This method is optional. If not used, the SDK will proceed without applying a specific consent flag.