Skip to content

Fix MediaContent-related API not being generated#1356

Open
marius-bughiu wants to merge 3 commits into
dotnet:mainfrom
marius-bughiu:fix/mediacontent-api
Open

Fix MediaContent-related API not being generated#1356
marius-bughiu wants to merge 3 commits into
dotnet:mainfrom
marius-bughiu:fix/mediacontent-api

Conversation

@marius-bughiu

@marius-bughiu marius-bughiu commented Feb 1, 2026

Copy link
Copy Markdown

Fixes: #973
Needed for: marius-bughiu/Plugin.AdMob#100

Problem

The IMediaContent interface was not being generated because it contained obfuscated methods (zza(), zzb()) that referenced internal types (com.google.android.gms.internal.ads.zzbfs). This caused the binding generator to skip the entire interface.

As a result, the MediaContent property on NativeAd, MediaView, and related classes was unavailable to .NET developers.

Solution

Added <remove-node> rules to the Metadata.xml transform files to exclude the problematic obfuscated methods from the MediaContent interface:

<remove-node path="/api/package[@name='com.google.android.gms.ads']/interface[@name='MediaContent']/method[@name='zza']" />
<remove-node path="/api/package[@name='com.google.android.gms.ads']/interface[@name='MediaContent']/method[@name='zzb']" />

New API Surface

Android.Gms.Ads.IMediaContent interface with:

  • AspectRatio
  • CurrentTime
  • Duration
  • HasVideoContent
  • MainImage
  • VideoController

MediaContent property now available on:

  • NativeAd
  • MediaView
  • INativeCustomFormatAd

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adjusts binding metadata for Google Play Services Ads so MediaContent / IMediaContent is generated again (by removing problematic obfuscated members), restoring expected managed API surface for native ads.

Changes:

  • Add remove-node rules for com.google.android.gms.ads.MediaContent.zza/zzb in Ads and Ads.Lite Metadata transforms.
  • Update play-services-ads-lite PublicAPI baseline to include Android.Gms.Ads.IMediaContent and related native-ad APIs.
  • PublicAPI baseline updates also appear in unrelated packages (kotlinx-* and ads-identifier).

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
source/com.google.android.gms/play-services-ads/Transforms/Metadata.xml Adds targeted removals for MediaContent.zza/zzb (but duplicates an existing broad zz* method removal rule).
source/com.google.android.gms/play-services-ads-lite/Transforms/Metadata.xml Adds targeted removals for MediaContent.zza/zzb to prevent interface generation from being blocked.
source/com.google.android.gms/play-services-ads-lite/PublicAPI/PublicAPI.Unshipped.txt Records newly generated IMediaContent and native-ad related API surface in the public API baseline.
source/org.jetbrains.kotlinx/kotlinx-serialization-core-jvm/PublicAPI/PublicAPI.Unshipped.txt Adds new KotlinX.Serialization API entries (not described by the PR).
source/org.jetbrains.kotlinx/atomicfu-jvm/PublicAPI/PublicAPI.Unshipped.txt Adds new AtomicFU API entries (not described by the PR).
source/com.google.android.gms/play-services-ads-identifier/PublicAPI/PublicAPI.Unshipped.txt Swaps obfuscated method signatures in the public API baseline (not described by the PR).

Comment on lines +114 to +118
<!-- MediaContent API bindings -->
<!-- Remove obfuscated methods from MediaContent interface that reference internal types -->
<remove-node path="/api/package[@name='com.google.android.gms.ads']/interface[@name='MediaContent']/method[@name='zza']" />
<remove-node path="/api/package[@name='com.google.android.gms.ads']/interface[@name='MediaContent']/method[@name='zzb']" />

Copilot AI Feb 23, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this Metadata.xml you already have a global <remove-node path="/api/*/*/method[contains(@name, 'zz')]" /> rule (line 40) which should remove MediaContent.zza/zzb as well. These new remove-node entries are redundant and may confuse future maintainers about which rule is actually required; consider removing the duplicate rules or narrowing/removing the global rule and keeping only the targeted removals.

Suggested change
<!-- MediaContent API bindings -->
<!-- Remove obfuscated methods from MediaContent interface that reference internal types -->
<remove-node path="/api/package[@name='com.google.android.gms.ads']/interface[@name='MediaContent']/method[@name='zza']" />
<remove-node path="/api/package[@name='com.google.android.gms.ads']/interface[@name='MediaContent']/method[@name='zzb']" />

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@marius-bughiu this is kind of what I thought as well, do the new <remove-node/> entries added here, not actually do anything?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, for play-services-ads those lines were a no-op. I've dropped them, and reverted the play-services-ads NuGet revision bump too since that package no longer changes. The PR now only touches ads-lite.

marius-bughiu and others added 2 commits July 4, 2026 22:38
Bumps the 4th-component NuGet revision by 0.0.0.1 for the two
packages whose public API changes due to the MediaContent fix:

- Xamarin.GooglePlayServices.Ads: 125.1.0 -> 125.1.0.1
- Xamarin.GooglePlayServices.Ads.Lite: 124.0.0.5 -> 124.0.0.6

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@marius-bughiu

Copy link
Copy Markdown
Author

Tested the MediaContent APIs via marius-bughiu/Plugin.AdMob#100
The branch contains a Xamarin.GooglePlayServices.Ads.Lite.124.0.0.8.nupkg that can be used for further testing.

videoad

The play-services-ads transform already removes all zz* methods via its
global remove-node rule, and MediaContent ships in the ads-lite artifact
anyway, so the targeted removals there were a no-op. With no functional
change to play-services-ads, its NuGet revision bump is reverted too.
The actual fix lives in the ads-lite transform, which has no global zz*
rule - that is why IMediaContent was skipped by the generator.
@marius-bughiu marius-bughiu changed the title WIP Fix MediaContent-related API not being generated Fix MediaContent-related API not being generated Jul 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

NativeCustomFormatAd and related types missing from Ads/Ads.Lite

3 participants