Android

HellaAds Android SDK Integration Guide

Step-by-step guide to integrating the HellaAds SDK into your Android app — from adding dependencies and initializing the SDK, to loading banner, interstitial, and rewarded ads.

SDK Version: 1.2.57Min SDK: 23+Kotlin: 1.8.0+Last updated: 2026-11-23

Prerequisites

Before integrating the HellaAds SDK, make sure your development environment meets the following requirements:

ItemRequirement
Android StudioArctic Fox or higher
minSdk23 or higher
compileSdk36
Kotlin1.8.0 or higher
Android Gradle Plugin8.x

Step 1: Add Dependencies

Maven Repository

In the project root settings.gradle.kts, add mavenCentral() to the repository list:

KOTLIN
dependencyResolutionManagement {
    repositories {
        google()
        mavenCentral()
    }
}

SDK Dependency

In app/build.gradle.kts, add the SDK dependency:

KOTLIN
dependencies {
    implementation("io.github.hs-android:core:1.2.57")
}

Step 2: Configure AndroidManifest

Add Permissions

Declare the required permissions in your AndroidManifest.xml:

XML
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="com.google.android.gms.permission.AD_ID" />

Configure APP_KEY

Inside <application>, add the following:

XML
<meta-data
    android:name="com.hs.ads.APP_KEY"
    android:value="YOUR_APP_KEY" />

Network Security (Android 9.0+)

Inside <application>, reference the network security configuration:

XML
android:networkSecurityConfig="@xml/network_security_config"
XML
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
    <!-- Allow cleartext HTTP traffic; trust system-installed CA certificates (production environment) -->
    <base-config cleartextTrafficPermitted="true">
        <trust-anchors>
            <certificates src="system" />
        </trust-anchors>
    </base-config>
</network-security-config>

Step 3: Initialize the SDK

It is recommended to call the initialization method in Application.onCreate():

Initialization Code

KOTLIN
// Enable SDK logging in Application
class DemoApplication : Application() {
    override fun onCreate() {
        super.onCreate()
        // Call SDK initialization
        HellaAdsSdk.init(
            context,
            "YOUR_APP_KEY",
            null,
            object : HellaAdsSdk.OnInitListener {
                override fun onInitSuccess() {
                    // SDK initialized successfully — you may now request ads
                }

                override fun onInitFail(errorMsg: String?) {
                    // Initialization failed — verify APP_KEY and network connectivity
                }
            }
        )
    }
}

Always wait for onInitSuccess before making any ad requests. Requesting ads before initialization completes may result in load failures.

Interstitial Ad

Integrate a full-screen interstitial ad into your app.

Create an Instance

KOTLIN
private var interstitialAd: HSAdxInterstitial? = null

interstitialAd = HSAdxInterstitial("YOUR_UNIT_ID")

Load an Ad

KOTLIN
interstitialAd?.setAdLoadListener(object : IAdListener.AdLoadListener {
    override fun onAdLoaded(hellaAd: HellaAd?) {
        // Ad loaded successfully — ready to show
    }

    override fun onAdLoadError(adError: AdError?) {
        // Ad failed to load
    }
})
interstitialAd?.load()

Display the Ad

KOTLIN
if (interstitialAd?.isAdReady == true) {
    interstitialAd?.show()
}

Event Callbacks

KOTLIN
interstitialAd?.setAdActionListener(object : IAdListener.AdActionListener {
    override fun onAdImpression(hellaAd: HellaAd?) {
        // Ad impression recorded
    }

    override fun onAdClicked(hellaAd: HellaAd?) {
        // Ad clicked
    }

    override fun onAdRevenue(hellaAd: HellaAd?) {
        // Revenue callback — hellaAd?.revenue contains the eCPM value
    }

    override fun onAdClosed(hasRewarded: Boolean, hellaAd: HellaAd?) {
        // Ad closed
    }

    override fun onAdRewarded(hellaAd: HellaAd?) {}

    override fun onAdImpressionError(error: AdError?) {
        // Impression error
    }
})

Destroy

KOTLIN
override fun onDestroy() {
    interstitialAd?.destroy()
    interstitialAd = null
    super.onDestroy()
}

Rewarded Ad

Integrate a rewarded video ad and grant rewards on completion.

Create an Instance

KOTLIN
private var rewardAd: HSAdxReward? = null

rewardAd = HSAdxReward("YOUR_UNIT_ID")

Load an Ad

KOTLIN
rewardAd?.setAdLoadListener(object : IAdListener.AdLoadListener {
    override fun onAdLoaded(hellaAd: HellaAd?) {
        // Ad loaded successfully — ready to show
    }

    override fun onAdLoadError(adError: AdError?) {
        // Ad failed to load
    }
})
rewardAd?.load()

Display the Ad

KOTLIN
if (rewardAd?.isAdReady == true) {
    rewardAd?.show()
}

Event Callbacks

KOTLIN
rewardAd?.setAdActionListener(object : IAdListener.AdActionListener {
    override fun onAdImpression(hellaAd: HellaAd?) {
        // Ad impression recorded
    }

    override fun onAdClicked(hellaAd: HellaAd?) {
        // Ad clicked
    }

    override fun onAdRevenue(hellaAd: HellaAd?) {
        // Revenue callback — hellaAd?.revenue contains the eCPM value
    }

    override fun onAdRewarded(hellaAd: HellaAd?) {
        // User completed the rewarded action — grant in-game reward here
    }

    override fun onAdClosed(hasRewarded: Boolean, hellaAd: HellaAd?) {
        // Ad closed; hasRewarded = true if the user earned a reward
    }

    override fun onAdImpressionError(error: AdError?) {
        // Impression error
    }
})

Destroy

KOTLIN
override fun onDestroy() {
    rewardAd?.destroy()
    rewardAd = null
    super.onDestroy()
}

Callback Reference

The following callbacks are available across the three ad formats:

CallbackTriggerBannerInterstitialRewarded
onAdLoadedAd loaded successfully✓✓✓
onAdLoadErrorAd load failed✓✓✓
onAdImpressionAd impression recorded✓✓✓
onAdClickedAd clicked✓✓✓
onAdRevenueRevenue data returned✓✓✓
onAdClosedAd closed✓✓✓
onAdRewardedUser completed rewarded action——✓
onAdImpressionErrorImpression error✓✓✓

Best Practices

  1. 1

    Ad Object Reuse: Reuse the same ad object for a given ad unit. If switching ad units, call destroy() on the existing object before creating a new one.

  2. 2

    Check isAdReady: Always verify isAdReady before calling show() to avoid displaying an ad that has not fully loaded.

  3. 3

    Lifecycle Management: Call destroy() in onDestroy() to release resources and prevent memory leaks.

  4. 4

    Rewarded Ad Grant Logic: Issue in-game rewards inside onAdRewarded. Do not rely solely on onAdClosed's hasRewarded parameter as the authoritative signal.