Skip to content
github-actions[bot] edited this page Jul 29, 2026 · 11 revisions

AdManageKit

JitPack API License

AdManageKit is a comprehensive Android library designed to simplify the integration and management of Google AdMob ads, Google Play Billing, and User Messaging Platform (UMP) consent.

Latest Version: 4.4.2

What's New in 4.4.2

Bug-fix release, no API changes. Two deliberate behavior changes are noted below.

  • Rewarded ads could crash — every show-path callback, including onRewardEarned, was delivered on a background thread
  • A completed purchase could fail to disable ads until the next app launch
  • Blank gaps where banner/native slots should have collapsed, for premium users and after a failed load, in both XML and Compose
  • App open ads could appear over excluded screens, including flows protected by disableAppOpenAdsTemporarily()
  • BannerAdView leaked its Activity and kept requesting ads after being detached

Behavior changes: an account-hold subscription no longer disables ads (it already reported ON_HOLD and failed isSubscriptionActive()), and premium users no longer reserve ad space in Compose.

Recent Highlights

  • 4.4.1 — Google Mobile Ads Next-Gen SDK 1.3.0 (from 1.2.1), plus repairs to API doc generation and the MCP documentation server
  • 4.4.0 — Subscription offers can be purchased individually (subscribe(activity, offer)), offer lookup by id/base plan/tag, cross-cadence price normalization (BillingPeriod, getSavingsPercent), trial eligibility, Play Billing 9 one-time product offers, and client-side account hold detection. See Subscription Offers
  • 4.3.x — All standard banner sizes (BannerAdSize), custom native templates, and app-open ad freshness enforcement
  • 4.2.0 — Migrated to the Google Mobile Ads Next-Gen SDK and Play Billing 9. MobileAds.initialize() must now be called explicitly before any ad request

Upgrading from 3.x or earlier? Read the Migrating to 4.2.0 notes first — it is the one release in the 4.x line that is not source-compatible.

Full details: Changelog · Release Notes

Features

AdMob Ads Management

  • Banner Ads: Auto-refresh, collapsible banners, smart retry
  • Native Ads: Small, Medium, Large formats with caching
  • Interstitial Ads: Time/count-based triggers, dialog support, loading strategies
  • App Open Ads: Lifecycle-aware with activity exclusion

NativeTemplateView (v2.6.0+)

  • 38 Template Styles: card_modern, material3, minimal, list_item, magazine, app_store, social_feed, spotlight, plus the video_* and flat_* families
  • XML & Programmatic: Set templates via app:adTemplate or setTemplate()
  • Custom Templates (v4.3.0+): supply your own layout via setCustomTemplate() or app:customAdLayout
  • Material 3 Theming: Automatic dark/light mode support

Ad Loading Strategies (v2.6.0+)

  • ON_DEMAND: Fetch fresh ads with loading dialog
  • ONLY_CACHE: Instant display from cache
  • HYBRID: Cache-first with fallback fetch (recommended)
  • FRESH_WITH_CACHE_FALLBACK: Fetch fresh, fall back to cache on failure

Centralized Configuration

  • AdManageKitConfig: Single configuration point
  • Environment-specific settings (debug vs production)
  • Runtime configuration changes

Reliability & Performance

  • Smart retry with exponential backoff
  • Circuit breaker for failing ad units
  • Memory leak prevention with WeakReference

Privacy & Compliance

  • UMP consent management (GDPR/CCPA)
  • Automatic ad hiding for purchased users

Getting Started

Installation

Step 1: Add JitPack to your root build.gradle:

dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        mavenCentral()
        maven { url 'https://jitpack.io' }
    }
}

Step 2: Add dependencies to your app's build.gradle:

implementation 'com.github.i2hammad.AdManageKit:ad-manage-kit:v4.4.2'
implementation 'com.github.i2hammad.AdManageKit:ad-manage-kit-billing:v4.4.2'
implementation 'com.github.i2hammad.AdManageKit:ad-manage-kit-core:v4.4.2'

// For Jetpack Compose support
implementation 'com.github.i2hammad.AdManageKit:ad-manage-kit-compose:v4.4.2'

// For Yandex Ads multi-provider support
implementation 'com.github.i2hammad.AdManageKit:ad-manage-kit-yandex:v4.4.2'

Step 3: Ensure your app's compileSdk is 37 or higher (required transitively as of 4.2.0).

Step 4: Sync your project with Gradle.

Quick Configuration

Configure AdManageKit in your Application class:

Since 4.2.0 you must call MobileAds.initialize() yourself. The Next-Gen SDK removed the legacy SDK's silent lazy-init, so an app that skips it never loads ads. AdManageKit does not call it for you, because it does not own your consent flow.

class MyApp : Application() {
    var appOpenManager: AppOpenManager? = null

    override fun onCreate() {
        super.onCreate()

        initAds()

        // Set up billing
        BillingConfig.setPurchaseProvider(BillingPurchaseProvider())

        // Configure AdManageKit
        AdManageKitConfig.apply {
            debugMode = BuildConfig.DEBUG
            enableSmartPreloading = true
            autoRetryFailedAds = true

            // Ad Loading Strategies
            interstitialLoadingStrategy = AdLoadingStrategy.HYBRID
            appOpenLoadingStrategy = AdLoadingStrategy.HYBRID
            nativeLoadingStrategy = AdLoadingStrategy.HYBRID

            // Auto-reload interstitial after showing
            interstitialAutoReload = true  // default: true
        }
    }

    private fun initAds() {
        val config = InitializationConfig.Builder(readApplicationIdFromManifest()).build()

        // initialize() blocks, so keep it off the main thread or it can ANR.
        Thread {
            MobileAds.initialize(this, config)

            // Construct AppOpenManager only after initialize() returns. Constructing it
            // arms its ProcessLifecycleOwner observer, and onStart() fires as soon as any
            // activity starts — created earlier, that observer can race ahead of
            // initialization and issue a load the Next-Gen SDK rejects as "not initialized".
            Handler(Looper.getMainLooper()).post {
                appOpenManager = AppOpenManager(this, "your-app-open-ad-unit-id")
            }
        }.start()
    }
}

The Next-Gen SDK no longer reads the application id from the manifest automatically, so readApplicationIdFromManifest() pulls com.google.android.gms.ads.APPLICATION_ID from your ApplicationInfo metadata. See the sample app's MyApplication.kt for the full version.

Wiki Pages

Ad Types

Features

Multi-Provider Ads

Billing

Sample Project

The app module demonstrates all features. To run:

  1. Clone: git clone https://github.com/i2hammad/AdManageKit.git
  2. Open in Android Studio
  3. Replace placeholder AdMob IDs
  4. Run on device or emulator

Support

Buy me a coffee

For issues: GitHub Issues or hammadmughal0001@gmail.com

License

Licensed under the MIT License. See LICENSE.

Clone this wiki locally