Skip to main content

Installation

📦 Add the Package​

Add ocm_ads from pub.dev:

flutter pub add ocm_ads

Or add it to your app's pubspec.yaml yourself and fetch packages:

dependencies:
ocm_ads: ^0.0.5
flutter pub get

Import the plugin wherever you show ads:

import 'package:ocm_ads/ocm_ads.dart';

🤖 Android Setup​

Step 1: Set the Minimum SDK​

The OCM Android SDK requires API 25. Set it in android/app/build.gradle (or build.gradle.kts):

android {
defaultConfig {
minSdkVersion 25
}
}

Build with Java 17.

Step 2: Configure AndroidManifest.xml​

Add the network permissions and your Google Mobile Ads application ID to android/app/src/main/AndroidManifest.xml:

<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

<application>
<!-- Replace with your own App ID -->
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-3940256099942544~3347511713" />
</application>
</manifest>
Important

Replace Google's test App ID (ca-app-pub-3940256099942544~3347511713) with your own Google AdMob or GAM Application ID before deploying to production. The app crashes on launch without an application ID.

info

Gradle pulls in the native dependency com.orangeclickmedia.adnetwork:adnetwork-sdk:1.1.9 from Maven Central, along with the Google Mobile Ads SDK and Prebid, so no other Gradle configuration is required.


🍎 iOS Setup​

The plugin supports both Swift Package Manager and CocoaPods. The minimum deployment target is iOS 15.0.

When Flutter's Swift Package Manager integration is on, the plugin resolves the OCM iOS SDK 1.2.7 release from the public SwiftPM distribution repository. There's nothing to add by hand.

To turn SwiftPM on (or back on after using CocoaPods):

flutter config --enable-swift-package-manager
flutter clean
flutter pub get
flutter run

Option B: CocoaPods​

If your app doesn't use SwiftPM, the plugin's podspec depends on OCMAdNetworkIOS ~> 1.2.7. Turn SwiftPM off and install pods:

flutter config --no-enable-swift-package-manager
flutter clean
flutter pub get
cd ios
pod install --repo-update

Make sure ios/Podfile targets iOS 15.0 or newer:

platform :ios, '15.0'

Configure Info.plist​

Add your Google Mobile Ads application ID and the App Tracking Transparency message to ios/Runner/Info.plist:

<key>GADApplicationIdentifier</key>
<string>ca-app-pub-3940256099942544~1458002511</string>
<key>NSUserTrackingUsageDescription</key>
<string>This identifier will be used to deliver personalized ads to you.</string>
Important

Replace Google's test App ID (ca-app-pub-3940256099942544~1458002511) with your own before deploying to production. The app crashes on launch without an application ID.

Also add the SKAdNetworkItems identifiers required by the ad networks you enable.

Add App Transport Security exceptions only if your inventory requires them:

<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key><true/>
<key>NSAllowsArbitraryLoadsForMedia</key><true/>
<key>NSAllowsArbitraryLoadsInWebContent</key><true/>
</dict>

✅ Verify Installation​

Rebuild and run your app on each platform:

flutter run

If the build succeeds and the app launches, the plugin is properly installed.


🔧 Troubleshooting​

iOS Issues​

Calls fail with unsupported_platform ("OCMAdNetworkIOS is not available"):

  • The native iOS SDK wasn't linked. Check that either SwiftPM is enabled, or that SwiftPM is disabled and pod install ran successfully.

CocoaPods can't resolve OCMAdNetworkIOS:

cd ios
pod install --repo-update

Deployment target errors:

  • Set the iOS deployment target to 15.0 or newer in Xcode and in ios/Podfile.

App crashes on launch:

  • Check that GADApplicationIdentifier is set in Info.plist.

Android Issues​

Manifest merger fails with minSdkVersion ... cannot be smaller than version 25:

  • Flutter's default flutter.minSdkVersion is lower than 25. Set minSdkVersion 25 in android/app/build.gradle.

App crashes on launch:

  • Check that the com.google.android.gms.ads.APPLICATION_ID meta-data is in AndroidManifest.xml.

Build fails with a Java version error:

  • Build with JDK 17.

Next Steps​

Continue to Getting Started to initialize the SDK and load your first ad.