Introduction to applovin_admob_sdk

Managing multiple ad networks in mobile applications often leads to fragmented implementations, redundant code, and complex mediation setups. The applovin_admob_sdk Flutter package solves this issue by combining Google AdMob and AppLovin MAX under a unified API surface in Flutter. Instead of writing distinct boilerplate code for each platform, this package abstracts the mediation layer, letting your application request ads while automatically optimizing fill rates and eCPMs behind the scenes.

Key Features and When to Use It

The applovin_admob_sdk package is ideal for Flutter applications seeking to maximize ad revenue across both iOS and Android platforms without maintaining multiple distinct ad plugins. Primary capabilities include:

  • Unified API: Load and display banners, interstitials, and rewarded videos across both Google AdMob and AppLovin MAX from a single interface.
  • Built-in Privacy Suite: Built-in support for user consent mechanisms covering GDPR, COPPA, and CCPA regulations.
  • Reactive Event Streams: Typed Dart streams for real-time tracking of ad loading, impressions, clicks, and rewards.
  • Debug Tools: Built-in debug overlay to test mediation setups and fill behaviors during development.

Note: While applovin_admob_sdk streamlines native mobile ad mediation, it currently supports iOS and Android target platforms only. Web and desktop platforms are not supported.

Installation and Setup

To add the applovin_admob_sdk package to your Flutter project, run the following command in your terminal:

Code
flutter pub add applovin_admob_sdk

Native Android and iOS Configuration

Before initializing the package in Dart code, make sure to configure both Android and iOS manifest files with your respective network app keys as required by Google Mobile Ads and AppLovin MAX:

  • Android: Ensure your AndroidManifest.xml contains the standard Google Mobile Ads App ID metadata tag and necessary network permissions.
  • iOS: Add your Google App ID and AppLovin SDK keys to your Info.plist file alongside required SKAdNetworkItems entries. Refer to official pub.dev documentation or vendor guides for specific plist keys.

Step-by-Step Implementation: Rewarded Video Ads

Below is a production-ready example demonstrating how to initialize rewarded ads, listen to ad lifecycle events using typed streams, and grant rewards to users upon ad completion.

Dart / Flutter
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:applovin_admob_sdk/applovin_admob_sdk.dart';

class RewardedAdButton extends StatefulWidget {
  const RewardedAdButton({Key? key}) : super(key: key);

  @override
  State<RewardedAdButton> createState() => _RewardedAdButtonState();
}

class _RewardedAdButtonState extends State<RewardedAdButton> {
  late final StreamSubscription<AdEvent> _subscription;
  bool _isReady = false;
  static const String _rewardedUnitId = 'YOUR_REWARDED_UNIT_ID';

  @override
  void initState() {
    super.initState();
    // Request loading a rewarded ad
    ApplovinAdmobSdk.loadRewardedAd(unitId: _rewardedUnitId);

    // Listen to ad lifecycle events reactively
    _subscription = ApplovinAdmobSdk.adEventStream.listen((event) {
      if (event is AdLoaded && event.unitId == _rewardedUnitId) {
        setState(() => _isReady = true);
      } else if (event is AdFailedToLoad) {
        // Handle load failure gracefully
        setState(() => _isReady = false);
      } else if (event is AdRewarded) {
        // Reward the user here
        if (mounted) {
          ScaffoldMessenger.of(context).showSnackBar(
            const SnackBar(content: Text('Reward successfully granted!'))
          );
        }
      }
    });
  }

  @override
  void dispose() {
    _subscription.cancel();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return ElevatedButton(
      onPressed: _isReady
          ? () {
              ApplovinAdmobSdk.showRewardedAd(unitId: _rewardedUnitId);
            }
          : null,
      child: Text(_isReady ? 'Watch Rewarded Ad' : 'Loading Ad...'),
    );
  }
}

Common Pitfalls and Best Practices

  • Uncancelled Stream Subscriptions: Always cancel your adEventStream subscriptions in your widget's dispose() method to prevent memory leaks.
  • Unconfigured Native Manifests: Ensure both AdMob App IDs and AppLovin SDK keys are correctly declared in native configuration files; missing keys will result in runtime initialization crashes on startup.
  • Testing with Production Ad Units: Always use dedicated test unit IDs during active development to avoid policy flags on real monetization accounts.

Alternatives and Ecosystem Comparison

Depending on your application's architecture, you might consider alternatives such as google_mobile_ads for pure AdMob implementations, or official single-network plugins like applovin_max. However, using applovin_admob_sdk eliminates the need to manage two separate mediation SDK plugins manually in your Flutter project.

Frequently Asked Questions

Does applovin_admob_sdk support web or desktop platforms?

No, applovin_admob_sdk is designed exclusively for native mobile operating systems (iOS and Android). Web and desktop platforms are not supported.

How does applovin_admob_sdk handle privacy and GDPR compliance?

The package includes a built-in privacy helper suite capable of presenting user consent dialogs for GDPR, COPPA, and CCPA regulations, storing choices securely and applying relevant consent flags to ad requests.

Can I show banners, interstitials, and rewarded video ads with this package?

Yes, applovin_admob_sdk provides a unified API for managing banners, interstitials, and rewarded video ad formats across both AdMob and AppLovin MAX.