Skip to content

gamezop/gma-android-webview-example

Repository files navigation

GMA Android WebView Example

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 WebView settings recommended for ad monetization
  • Registers the WebView with the Google Mobile Ads SDK
  • Opens off-domain links outside the app

Official Reference

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.

What This Sample Implements

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 active WebView
  • Required manifest metadata for the WebView Ads integration

Project Structure

How The App Works

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 WebViewClient so first-party URLs remain inside the app
  • Opens external destinations with an Android Intent
  • Registers the WebView with Google Mobile Ads
  • Loads the configured network URL

Current Website 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.

Run The Sample

Prerequisites

  • Android Studio with Android SDK installed
  • JDK 17
  • Android device or emulator with Google Play services

Build and install

./gradlew assembleDebug

You can then run the app from Android Studio or install the generated APK on a device.

Validation Checklist

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 WebView is connected to the Google Mobile Ads SDK

Important Notes For Partners

  • 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_ID check for WebView Ads integration.
  • If your web content uses consent flows, consent handling inside WebView should 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.

No Behavioral Changes

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.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages