Skip to content

About

Simple project to implement Adivery.

Resources

Stars

3 stars

Watchers

1 watching

Forks

Repository files navigation

Adivery Android sample

A working example of every Adivery placement type, implemented twice: once in Kotlin and once in Java. Import the project into Android Studio and run it — it ships with Adivery's public demo credentials, so no dashboard account is needed to try it out.

Full documentation: https://adivery.com/android

Placement types

Placement Kotlin Java
Interstitial KotlinInterstitialActivity JavaInterstitialActivity
Rewarded KotlinRewardedActivity JavaRewardedActivity
App open KotlinAppOpenActivity JavaAppOpenActivity
Offer wall KotlinOfferWallActivity JavaOfferWallActivity
Banner KotlinBannerActivity JavaBannerActivity
Native KotlinNativeActivity JavaNativeActivity
Pre-Roll (VAST) KotlinVastActivity JavaVastActivity

Each screen requests an ad, shows it, and prints every SDK callback it receives so the ad lifecycle is visible while the sample runs.

The offer wall works differently from the other full screen formats. It is loaded only when the user taps its button and shown as soon as it loads.

Jetpack Compose

Adivery has no Compose artifact and does not need one, so instead of repeating all seven placements a third time the sample covers only the parts where Compose changes the integration:

File What it shows
AdiveryCompose.kt AdiveryBanner and AdiveryNativeAd — the whole interop layer, since banner and native placements are Views and Compose hosts them with AndroidView. Copy this file into your app as is
ComposeShowcaseActivity.kt Those two composables in use, plus an interstitial whose listener is registered and released by a DisposableEffect

Interstitial, rewarded, app open, offer wall and Pre-Roll are the same static Adivery calls from Compose as from a View, so only the interstitial is repeated here; the rest are left to the screens above.

Supporting code

File What it shows
SampleApplication.kt Adivery.configure and Adivery.setLoggingEnabled, called once per process
AppOpenAdManager.kt The recommended app open pattern: show the ad when the user returns after a few seconds away
view_native_ad.xml The native ad template and the view ids AdiveryNativeAdView populates
activity_vast_ad.xml The ExoPlayer PlayerView the pre-roll plays in, and the 320×50 slot IMA draws the companion banner into
proguard-rules.pro A local copy of the keep/dontwarn rules the SDK already contributes through its own consumer rules, kept because the documentation links to this file
ProfileStore.kt, CreateProfileActivity.kt Sample plumbing only — storage for the credentials the sample runs with
Wallet.kt Sample plumbing only — the balance the offer wall's rewards are added to

Running with your own credentials

The home screen's New profile button takes an application id and one placement id per type from the Adivery publisher panel; the offer wall placement id is optional. Select the new profile and press Apply; because Adivery.configure runs once per process, the sample restarts to pick it up.

Requirements

  • minSdk 21 or above
  • The SDK ships its own manifest entries and ProGuard rules, so adding the dependency is enough:
dependencies {
    implementation("com.adivery:sdk:4.10.0-alpha.1")
}

Pre-Roll is the exception: Adivery only hands out the VAST url, so that screen also needs a video player able to read it.

dependencies {
    implementation("androidx.media3:media3-exoplayer:1.8.1")
    implementation("androidx.media3:media3-ui:1.8.1")
    implementation("androidx.media3:media3-exoplayer-ima:1.8.1")
}

The Compose screen brings Compose itself, which nothing else in the sample uses. Note that buildFeatures.compose = true is not sufficient on its own — since Kotlin 2.0 the Compose compiler is a separate Gradle plugin, and it has to be pinned to the Kotlin version your AGP builds with (./gradlew :app:dependencies reports it as kotlin-stdlib).

plugins {
    id("org.jetbrains.kotlin.plugin.compose") version "2.2.10"
}

dependencies {
    implementation(platform("androidx.compose:compose-bom:2024.12.01"))
    implementation("androidx.compose.material3:material3")
    implementation("androidx.activity:activity-compose:1.9.3")
}

About

Simple project to implement Adivery.

Resources

Stars

3 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages