Fix MediaContent-related API not being generated#1356
Conversation
There was a problem hiding this comment.
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-noderules forcom.google.android.gms.ads.MediaContent.zza/zzbin Ads and Ads.Lite Metadata transforms. - Update
play-services-ads-litePublicAPI baseline to includeAndroid.Gms.Ads.IMediaContentand 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). |
| <!-- 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']" /> | ||
|
|
There was a problem hiding this comment.
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.
| <!-- 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']" /> |
There was a problem hiding this comment.
@marius-bughiu this is kind of what I thought as well, do the new <remove-node/> entries added here, not actually do anything?
There was a problem hiding this comment.
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.
cb724a3 to
02049e7
Compare
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>
3bf3145 to
fc6d213
Compare
|
Tested the MediaContent APIs via marius-bughiu/Plugin.AdMob#100
|
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.

Fixes: #973
Needed for: marius-bughiu/Plugin.AdMob#100
Problem
The
IMediaContentinterface 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
MediaContentproperty onNativeAd,MediaView, and related classes was unavailable to .NET developers.Solution
Added
<remove-node>rules to theMetadata.xmltransform files to exclude the problematic obfuscated methods from theMediaContentinterface:New API Surface
Android.Gms.Ads.IMediaContentinterface with:AspectRatioCurrentTimeDurationHasVideoContentMainImageVideoControllerMediaContentproperty now available on:NativeAdMediaViewINativeCustomFormatAd