Skip to content
Open Portal

Android SDK

Integrate Appylar in your Android app.

Applies to Appylar v1.0

The Appylar Android SDK (v1.0.0) lets your app request and display ads, and — through campaigns — promote your app across the network. It has no third-party dependencies, ships as a ~114 KB AAR, and talks only to https://api.appylar.com. This page covers the complete public API.

You need an app key (app_live_…) from the portal before you start. See Getting Started.

#Requirements

Min SDK24 (Android 7.0)
Compile SDK34
Java/Kotlin target17
DistributionMaven Central

The SDK merges the permissions it needs (INTERNET, ACCESS_NETWORK_STATE) into your manifest — you don't need to add them.

#Installation

Add Maven Central and the dependency.

// settings.gradle.kts
dependencyResolutionManagement {
    repositories {
        google()
        mavenCentral()
    }
}
// app/build.gradle.kts
dependencies {
    implementation("com.appylar:appylar-sdk:1.0.0")
}

#initialize()

Call initialize once, as early as possible — Application.onCreate() or your launcher activity. It's non-blocking, idempotent, and uses the application context (no leak). It also reports the install event for you.

import com.appylar.sdk.Appylar

Appylar.initialize(context, "app_live_xxx")

Passing a blank app key throws IllegalArgumentException. There is no shutdown() — re-calling initialize safely replaces the previous configuration.

#Configuration

Pass an optional AppylarConfig to enable test mode or change logging.

import com.appylar.sdk.AppylarConfig
import com.appylar.sdk.LogLevel

Appylar.initialize(
    context,
    "app_live_xxx",
    AppylarConfig(testMode = false, logLevel = LogLevel.INFO),
)
  • testMode — when true, the SDK uses the sandbox and serves deterministic test ads. Default false.
  • logLevelNONE, ERROR, WARN, INFO (default) or DEBUG.

Provide consent explicitly with two booleans. You can call setConsent any time and update it later.

import com.appylar.sdk.Consent

Appylar.setConsent(Consent(gdprConsent = true, childDirected = false))
  • gdprConsent — the user has consented to personalized advertising (GDPR/TCF).
  • childDirected — COPPA. When true, the SDK runs in contextual-only mode with no identifiers, regardless of gdprConsent.

The SDK does not show a consent dialog. Collect consent with your own CMP and pass the result to setConsent.

A BannerView is a FrameLayout subclass, so you add it to your layout like any view. It loads itself automatically once it's attached to the window — there's no load() call and no auto-refresh. The served creative scales to fit the view, so size it with normal layout params.

import com.appylar.sdk.Appylar
import com.appylar.sdk.BannerListener
import com.appylar.sdk.AdError

val banner = Appylar.bannerView(this)
banner.listener = object : BannerListener {
    override fun onLoaded() { /* shown */ }
    override fun onFailedToLoad(error: AdError) { /* e.g. NO_FILL */ }
}
container.addView(banner)

Call banner.destroy() when you remove it (see Lifecycle). After destroy() a banner will not load again.

#Interstitial

Create an interstitial via the factory, load it, and show it when it's ready.

import com.appylar.sdk.Appylar
import com.appylar.sdk.InterstitialListener
import com.appylar.sdk.AdError

val interstitial = Appylar.createInterstitial()
interstitial.listener = object : InterstitialListener {
    override fun onLoaded() = interstitial.show(this@MainActivity)
    override fun onFailedToLoad(error: AdError) { }
    override fun onShown() { }
    override fun onDismissed() { }
}
interstitial.load()

show(activity) must be called on the main thread. It's a no-op if nothing is loaded or an interstitial is already showing.

#Callbacks

Both listeners have default (no-op) methods, so you only override what you need.

ListenerMethodWhen
BannerListeneronLoaded()Banner loaded and rendered
onFailedToLoad(error)Load failed
InterstitialListeneronLoaded()Ad ready to show
onFailedToLoad(error)Load failed
onShown()Ad presented
onDismissed()Ad closed

All callbacks are delivered on the main thread.

#Errors

Failures arrive through onFailedToLoad(error: AdError). AdError has exactly four values:

ValueMeaning
NO_FILLNo eligible ad right now — expected, not a bug
NETWORK_ERRORNetwork or server error (transport is retried internally)
NOT_INITIALIZEDAppylar.initialize() hasn't run, or the key is invalid
INVALID_STATEe.g. showing an interstitial before a successful load

#Lifecycle

  1. Appylar.initialize(...) once at startup.
  2. Banner: add it to your layout (it self-loads); call destroy() when removing it.
  3. Interstitial: load(), then show(activity) on onLoaded.
  4. Install tracking is automatic; queued events survive process death and are sent later.

The only lifecycle call you must make yourself is BannerView.destroy():

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

#Sample app

Space Dash is a complete reference app built on this SDK — initialize, consent, a banner and an interstitial, with real loading, loaded, no-fill and error states and correct lifecycle. It uses only the public API. Find it as the sample module in the Android SDK repository.

#Best practices

  • Initialize as early as possible so a token and config are ready before the first ad request.
  • Preload interstitials at natural break points; call show() from onLoaded.
  • Treat NO_FILL as normal — just don't show an ad.
  • Use LogLevel.DEBUG while integrating, then drop back to INFO.
  • Always destroy() banners to release resources.

#Distribution store

The SDK reports its OS on every ad request, and Appylar routes each ad's click-through to the matching store listing — Google Play by default on Android. If you ship a build to a different Android store, declare it so clicks route there:

Appylar.initialize(
    context,
    "app_live_xxx",
    AppylarConfig(store = AppylarStore.AMAZON_APPSTORE),
)

AppylarStore covers GOOGLE_PLAY, APPLE_APP_STORE, AMAZON_APPSTORE, HUAWEI_APPGALLERY and SAMSUNG_GALAXY_STORE. You only need it for non-default stores. See the serving protocol for how routing works.