Add Adrop to Android

Prerequisites

  • Install or update Android Studio to its latest version.

  • Make sure that your project meets these requirements:

    • Targets API level 23 (M) or higher

    • Uses Android 6.0 or higher

      • minSdkVersion 23

    • Uses Jetpack (AndroidX), which includes meeting these version requirements:

      • com.android.tools.build:gradle v7.3.0 or later

      • compileSdkVersion 33

    • Kotlin 1.8.20 or higher

  • Sign into Adrop using your email or Google account.


Add Adrop using the Adrop console

Adding Adrop to your app involves tasks both in the Adrop console and in your open Android project (for example, you download Adrop config files from the console, then move them into your Android project).

Step 1: Create an Adrop project

Before you can add Adrop to your Android app, you need to create an Adrop project to connect to your Android app.

Step 2: Register your app with Adrop

To use Adrop in your Android app, you need to register your app with your Adrop project. Registering your app is often called "adding" your app to your project.

Make sure to enter the package name that your app is actually using. The package name value is case-sensitive, and it cannot be changed for this Adrop Android app after it's registered with your Adrop project.

  1. Go to the Adrop console.

  2. In the center of the project app page, click the Android icon button to launch the setup workflow.

  1. Enter your app's package name in the Android package name field

    • A package name uniquely identifies your app on the device and in the Google Play Store.

    • A package name is often referred to as an application ID.

    • Find your app's package name in your module (app-level) Gradle file, usually app/build.gradle (example package name: com.yourcompany.yourproject).

    • Be aware that the package name value is case-sensitive, and it cannot be changed for this Adrop Android app after it's registered with your Adrop project.

  2. Enter other app information: App nickname.

    • App nickname: An internal, convenience identifier that is only visible to you in the Adrop console

  3. Click Register app.

Step 3: Add an Adrop configuration file

  1. Download adrop_service.json to obtain your Adrop Android platforms config file.

  2. Move your config file into your assets directory.

Step 4: Add Adrop SDK to your app

  1. In your module (app-level) Gradle file (usually <project>/build.gradle.kts or <project>/build.gradle), add the dependency for the Adrop in your app.

dependencies {
   implementation("io.adrop:adrop-ads:0.5.4")
}
  1. After adding the dependency, sync your Android project with Gradle files.

Step 5: Initialize Adrop in your app

The final step is to add initialization code to your application.

  1. Import the Adrop

  2. Initialize an Adrop instance with your app's Application Context

import io.adrop.ads.Adrop
// ..

override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.activity_main)
    
    // 1. use Application Context
    // 2. true for production
    // 3. If you are using this SDK in specific countries, 
    //    pass an array of ISO 3166 alpha-2 country codes.
    Adrop.initialize(
        application, 
        production = false,
        targetCountries = arrayOf<String>())
}

Next Steps

You're all set! Please register an Ad unit to show ads to users.

Learn how to Create your Ad unit.

Last updated