AdManageKit
AdManageKit is an open-source Android library designed to simplify the management of Google AdMob ads,tROI firebase tracking, in-app billing, and User Messaging Platform (UMP) consent in Android applications.
Install / Use
/learn @i2hammad/AdManageKitREADME
AdManageKit
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 3.4.4 fixes native ad show rate issues across all native views and adds null safety to RewardedAdManager.
Next-Gen GMA SDK Version
Beta Notice: The Next-Gen GMA SDK (
com.google.android.libraries.ads.mobile.sdk) is currently in beta by Google, and AdManageKit's nextgen branch is also in beta. The underlying Google SDK may receive breaking changes until it reaches stable release. For production use, the main branch is the stable option.
AdManageKit offers a Next-Gen GMA SDK version on the nextgen branch, featuring Google's modern preloader-based ad loading system.
Why Next-Gen?
| Feature | Main Branch (GMS SDK) | Next-Gen Branch |
|---------|----------------------|-----------------|
| SDK | play-services-ads (stable) | ads-mobile-sdk (beta) |
| Ad Loading | Traditional load/show | Preloader-based with auto-refill |
| Threading | Manual main thread dispatch | Automatic background thread safety |
| Buffer System | N/A | Configurable ad buffers per type |
| Background Handling | Basic | Smart pending ad queue |
Next-Gen Features
- Preloader System: SDK automatically loads next ad after one is consumed
- Background-Aware Ads: App open ads won't show when app is in background
- Pending Ad Queue: Ads that load while backgrounded are saved for return
- Configurable Buffers: Set how many ads to keep ready per type
// Next-Gen preloader configuration
AdManageKitConfig.apply {
enableInterstitialPreloader = true
enableAppOpenPreloader = true
interstitialPreloaderBufferSize = 2
}
Migration Compatibility
Both branches use the same callback signatures via type aliases:
AdKitError→ resolves to appropriate SDK error typeAdKitLoadError→ resolves to appropriate SDK load error typeAdKitValue→ resolves to appropriate SDK value type
Your callback implementations work on both branches without changes.
Which Version Should I Use?
| Use Case | Recommended | |----------|-------------| | Production apps (stable) | Main branch (v3.4.4) | | New projects wanting latest features | Nextgen branch (v4.1.1) | | Testing preloader system | Nextgen branch | | Risk-averse production | Main branch |
What's New in 3.4.4
Native Ad Show Rate Fix
Fixed low show rates across all native ad views (NativeBannerSmall, NativeBannerMedium, NativeLarge, NativeTemplateView). Parent container visibility was not restored after a previous load failure, causing ads to load but remain invisible.
NativeBannerMedium Impression Fix
setNativeAd() was deferred via post {} which risked never executing. Changed to synchronous call for reliable impression registration. Also fixed shimmer overlay on cached/waterfall ads.
RewardedAdManager Null Safety
RewardedAdManager no longer crashes when methods are called before initialize(). All 5 public entry points now validate the ad unit ID and return appropriate callbacks.
For previous versions, see the Changelog or individual release notes.
Screenshots
| NativeBannerSmall Ad | Interstitial Ad | App Open Ad | UMP Consent Form |
|----------------------|-----------------|-----------------|------------------|
|
|
|
|
|
Demo Video
Watch a short demo of AdManageKit in action:
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:v3.4.4'
implementation 'com.github.i2hammad.AdManageKit:ad-manage-kit-billing:v3.4.4'
implementation 'com.github.i2hammad.AdManageKit:ad-manage-kit-core:v3.4.4'
// For Jetpack Compose support
implementation 'com.github.i2hammad.AdManageKit:ad-manage-kit-compose:v3.4.4'
// For Yandex Ads multi-provider support
implementation 'com.github.i2hammad.AdManageKit:ad-manage-kit-yandex:v3.4.4'
</td>
<td>
implementation 'com.github.i2hammad.AdManageKit:ad-manage-kit-nextgen:v4.1.1'
implementation 'com.github.i2hammad.AdManageKit:ad-manage-kit-billing-nextgen:v4.1.1'
implementation 'com.github.i2hammad.AdManageKit:ad-manage-kit-core-nextgen:v4.1.1'
// For Jetpack Compose support
implementation 'com.github.i2hammad.AdManageKit:ad-manage-kit-compose-nextgen:v4.1.1'
</td>
</tr>
</table>
Step 3: Sync your project with Gradle.
Features
NativeTemplateView (v2.6.0+)
- 27 Template Styles: card_modern, material3, app_store, social_feed, gradient_card, pill_banner, medium_horizontal, flexible, icon_left, top_icon_media, spotlight, and more
- XML & Programmatic: Set templates via
app:adTemplateorsetTemplate() - Material 3 Theming: Automatic dark/light mode support
- AdChoices Control: Configure placement position (v2.9.0+)
- Video-Ready: All templates support video ads (120dp+ MediaView)
- View Documentation
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)
- View Documentation
Jetpack Compose Integration
- BannerAdCompose, NativeAdCompose, InterstitialAdCompose
- Programmatic native ads without predefined layouts
- ConditionalAd, CacheWarmingEffect utilities
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
- App Open Ads: Lifecycle-aware with activity exclusion
Centralized Configuration
- AdManageKitConfig: Single configuration point
- Environment-specific settings (debug vs production)
- Runtime configuration changes
Intelligent Native Ad Caching
- Screen-aware caching prevents collisions
- Smart preloading with usage patterns
- LRU cache with configurable expiration
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
Multi-Provider Waterfall (New)
- Multiple Ad Networks: Load ads from AdMob, Yandex, and more with automatic fallback
- Zero Code Changes: Configure provider chains once; all existing API calls use waterfall automatically
- Per-Ad-Type Chains: Configure different provider orders for each ad format
- Region-Based: Prioritize providers by user locale (e.g., Yandex first for Russia)
- View Waterfall Documentation
- Yandex Integration Guide
Multi-Module Architecture
- Core Module: Shared interfaces and configuration
- Compose Module: Jetpack Compose integration
- Billing Module: Google Play Billing Library v8
- Yandex Module: Yandex Ads SDK provider
Usage Guide
Quick Configuration
Configure AdManageKit in your Application class:
class MyApp : Application() {
private lateinit var appOpenManager: AppOpenManager
override fun onCreate() {
super.onCreate()
// Configure AdManageKit
AdManageKitConfig.apply {
debugMode = BuildConfig.DEBUG
enableSmartPreloading = true
autoRetryFailedAds = true
// Ad Loading Strategies (v2.6.0+)
interstitialLoadingStrategy = AdLoadingStrategy.HYBRID
appOpenLoadingStrategy = AdLoadingStrategy.HYBRID
nativeLoadingStrategy = AdLoadingStrategy.HYBRID
// Auto-reload ads after showing (v2.7.0+)
interstitialAutoReload = true // default: true
appOpenAutoReload = true // default: true
rewardedAutoReload = true // default: true
}
// Set up billing
BillingConfig.setPurchaseProvider(BillingPurchaseProvider())
// Initialize app open ads
appOpenManager = AppOpenManager(this, "your-app-open-ad-unit-id")
}
}
Multi-Provider Waterfall (Optional)
Add Yandex (or other providers) as fallback ad networks with zero changes to your existing ad loading code:
// Add Yandex module
implementation 'com.github.i2hammad.AdManageKit:ad-manage-kit-yandex:v3.4.4'
// In Application.onCreate(), after AdManageKitConfig setup:
YandexProviderRegistration.initialize(this)
val admob = AdMobProviderRegistration.create()
val yandex = YandexProviderRegistration.create()
// Map your AdMob ad unit IDs to Yandex equivalents
AdUnitMapping.register("ca-app-pub-xxx/your-interstitial", mapOf("yandex" to "R-M-XXXXXX-Y"))
AdUnitMapping.register("ca-app-pub-xxx/your-native", mapOf("yandex" to "R-M-XX
