This repository is a public Kotlin Android sample that demonstrates how to integrate the Google Mobile Ads SDK with a WebView-based experience, following Google's official Ad Manager guidance for WebView monetization.
The sample is intended for partners who want a minimal reference app that:
- Loads a hosted website inside Android
WebView - Applies the
WebViewsettings recommended for ad monetization - Registers the
WebViewwith the Google Mobile Ads SDK - Opens off-domain links outside the app
This sample follows these Google guides:
The documentation pages above were last updated by Google on March 12, 2026 UTC at the time this README was written.
The app includes the key items recommended in the Google documentation:
- Third-party cookies enabled on the
WebView - JavaScript enabled
- DOM storage enabled
- Automatic media playback enabled
- Content loaded with
loadUrl()using a network URL MobileAds.registerWebView(webView)called for the activeWebView- Required manifest metadata for the WebView Ads integration
app/src/main/java/com/gamezop/webviewexample/MainActivity.kt: Main sample implementationapp/src/main/AndroidManifest.xml: Android permissions and required metadataapp/build.gradle.kts: App dependencies and Android build settings
MainActivity renders a full-screen WebView using Compose AndroidView.
During WebView creation, the sample:
- Enables cookie support, including third-party cookies
- Applies ad-friendly
WebSettings - Sets a
WebViewClientso first-party URLs remain inside the app - Opens external destinations with an Android
Intent - Registers the
WebViewwith Google Mobile Ads - Loads the configured network URL
The sample currently points to (Test Gamezop URL):
https://peSLSV.play.gamezop.com/
For integration validation during development, Google recommends testing with:
https://google.github.io/webview-ads/test/
There is already a commented test URL inside MainActivity.kt that can be used for validation when needed.
- Android Studio with Android SDK installed
- JDK 17
- Android device or emulator with Google Play services
./gradlew assembleDebugYou can then run the app from Android Studio or install the generated APK on a device.
When validating the integration with Google's test page, confirm the following:
- Third-party cookies work
- First-party cookies work
- JavaScript is enabled
- DOM storage is enabled
- Video playback works inline
- Video playback starts automatically when expected
- The
WebViewis connected to the Google Mobile Ads SDK
- Google recommends loading monetized content from a network URL via
loadUrl()instead of loading local assets or dynamically generated HTML where possible. - The required manifest metadata is necessary to bypass the
APPLICATION_IDcheck for WebView Ads integration. - If your web content uses consent flows, consent handling inside
WebViewshould be considered separately based on your setup and CMP strategy. - This sample is intentionally simple and focused on demonstrating WebView Ads integration, not on production app architecture.
This repository documentation was written to explain the existing implementation. It does not require any functional code changes to understand the integration flow already present in the app.