Platform setup - bdlukaa/native_admob_flutter GitHub Wiki
- Android
- iOS
AdMOB only supports ads on mobile. Web and desktop are out of reach
It's recommended to create your projects with a flutter version greater than 1.22, otherwise the Native Ad can be blank. See #4 for more info.
To avoid issues such as #7, it's recommended to add a splashscreen to your app.
Useful links:
- https://pub.dev/packages/flutter_native_splash
- https://flutter.dev/docs/development/ui/advanced/splash-screen
If your flutter app was created before version 1.12, you may need to migrate to embeeding v2, otherwise a message like The plugin native_admob_flutter requires your app to be migrated to the Android embedding v2. Follow the steps on https://flutter.dev/go/android-project-migration and re-run this command. Exited (1) can show up when trying to build the project.
Add your ADMOB App ID (How to find it?) in AndroidManifest.xml. Learn more
<manifest>
<application>
<!-- Sample AdMob app ID: ca-app-pub-3940256099942544~3347511713 -->
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-xxxxxxxxxxxxxxxx~yyyyyyyyyy">
</application>
</manifest>Key Point: In a real app, it is important that you use your actual AdMob app ID, not the one listed above. If you're just looking to experiment with the SDK in a Hello World app, though, you can use the sample app ID shown above.
Important: This step is required. Failure to add this <meta-data> tag results in a crash with the message: The Google Mobile Ads SDK was initialized incorrectly.
Add the internet permission:
<manifest>
<application>
...
</application>
<uses-permission android:name="android.permission.INTERNET" />
</manifest>If you'll use NativeAds or BannerAds (Platform View Ads), change minSdkVersion to 19 or higher. It's the minimum sdk version required by flutter to use a PlatformView. Learn more
android {
defaultConfig {
minSdkVersion 19
}
}If you won't, change it to 16 or higher.
android {
defaultConfig {
minSdkVersion 16
}
}Update your app's Info.plist file to add two keys:
- A
GADApplicationIdentifierkey with a string value of your AdMob app ID (identified in the AdMob UI). - A
SKAdNetworkItemskey with Google'sSKAdNetworkIdentifiervalue ofcstr6suwn9.skadnetwork.
<key>GADApplicationIdentifier</key>
<string>ca-app-pub-3940256099942544~1458002511</string>
<key>SKAdNetworkItems</key>
<array>
<dict>
<key>SKAdNetworkIdentifier</key>
<string>cstr6suwn9.skadnetwork</string>
</dict>
</array>Or, edit it in the property list editor:
Key Point: In a real app, it is important that you use your actual AdMob app ID, not the one listed above. If you're just looking to experiment with the SDK in a Hello World app, though, you can use the sample app ID shown above.
Important: This step is required. Failure to do so results in a crash with the message: The Google Mobile Ads SDK was initialized incorrectly.
| Next: Initialize |
|---|
