Xamarin.GooglePlayServices.Ads Library Unusable Since 2021 - Callbacks Not Properly Adapted
维护者通常 2 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 5/5
- 预计耗时
- 一周以上
- 新手友好度
- 35/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 冷清
- 技术栈
- android, csharp
- 领域
- mobile-dev
调研方向
首先使用 Xamarin.GooglePlayServices.Ads 重现 callback 问题,并检查 issue 中列出的受影响 callback 类,包括 InterstitialAdLoadCallback 和 RewardedAdLoadCallback。将公开的 callback 签名与报告中描述的 Android 类型进行比较。当受影响的 callback 提供可用的类型化 override,且报告的编译和 JNI 冲突问题不再发生时,即表示完成。
由索引模型根据 Issue 内容生成。
描述
Android framework version
net9.0-android
Affected platform version
Description
I find it surprising that there is no unified issue addressing this, despite numerous reports scattered across the internet and users creating their own plugins to workaround this problem.
This issue has been present since 2021, making the Xamarin.GooglePlayServices.Ads library completely unusable. I am currently testing with the latest version 123.6.0.1, released on January 22, 2025.
Despite new versions being released, the issue has persisted for four years. There are multiple workarounds available, such as the one proposed here:
https://gist.github.com/dtaylorus/63fef408cec34999a1e566bd5fac27e5
However, in all related issues that get opened, people spam their own NuGet packages (mostly paid) that merely implement the same workaround.
But... how is it possible that no official issue exists here, and no serious fix is being considered?
Am I the only one using MAUI and AdMob? I am not deeply familiar with the inner workings of these libraries or how official they are in MAUI, but it is unfortunate that they remain broken, given MAUI's potential.
The Problem:
AdMob callbacks are implemented in classes where methods are overridden. However, many of these callbacks are not properly adapted in the C# bindings.
Example:
For implementing an Interstitial Ad (Android.Gms.Ads.Interstitial.InterstitialAd), an instance of the Android.Gms.Ads.Interstitial.InterstitialAdLoadCallback class must be passed to handle the callbacks.
Before the library broke five years ago, the correct implementation was:
public class InterstitialCallbackImplementation : Android.Gms.Ads.Interstitial.InterstitialAdLoadCallback {
public override void OnInterstitialAdLoaded(InterstitialAd interstitialAd) {
base.OnInterstitialAdLoaded(interstitialAd);
// Ok
}
public override void OnAdFailedToLoad(LoadAdError e) {
base.OnAdFailedToLoad(e);
// Fail
}
}
However, now the method OnInterstitialAdLoaded(InterstitialAd interstitialAd) does not exist for override.
Instead, there is another method:
public override void OnAdLoaded(Java.Lang.Object p0)
The binding does not correctly identify p0 as its corresponding type, InterstitialAd.
At first glance, this might seem like a minor issue—one could cast p0 as Android.Gms.Ads.Interstitial.InterstitialAd.
However, this does not work. Trying to do so results in compilation failures, JNI collisions, and a host of other issues.
With all the effort behind these libraries, it's baffling that a few improperly adapted parameters have rendered them completely unusable for five years.
Affected Classes:
com/google/android/gms/ads/admanager/AdManagerInterstitialAdLoadCallback
com/google/android/gms/ads/appopen/AppOpenAd$AppOpenAdLoadCallback
com/google/android/gms/ads/interstitial/InterstitialAdLoadCallback
com/google/android/gms/ads/rewarded/RewardedAdLoadCallback
com/google/android/gms/ads/rewardedinterstitial/RewardedInterstitialAdLoadCallback
Android.Gms.Ads.NativeAd.NativeAd.IOnNativeAdLoadedListener
Questions:
What is the current status of these libraries?
How is it possible that such a critical issue remains unresolved for so long?
Thank you.
Steps to Reproduce
Install Xamarin.GooglePlayServices.Ads and try to use it.
Did you find any workaround?
https://gist.github.com/dtaylorus/63fef408cec34999a1e566bd5fac27e5
Relevant log output
- 主要语言
- C#
- 星标
- 319
- 派生
- 73
- 平均合并
- 2 天 11 小时
- 30 天内合并 PR
- 8
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
dotnet/android-libraries 的其他 Issue
-
Unfreeze Xamarin.Firebase.Firestore and Xamarin.Protobuf.JavaLite now that Firebase BoM 35.0.0 fixes the Protolite conflict可能已有人在做 @jonathanpeppers 于 9 天前认领。 未关闭
dotnet/android-libraries#1563 · 1 个 reaction · 已指派 2 人 ·
维护者通常 2 天内回复
-
难度 1/5 1 小时以内 新手友好度 20/100
dotnet/android-libraries#1561 · 4 条评论 ·
维护者通常 2 天内回复
-
Regression: incorrect nullability annotations in Xamarin.AndroidX.AppCompat 1.8.0可能已有人在做 @jonathanpeppers 于 12 天前认领。 未关闭
难度 4/5 3-5 天 新手友好度 40/100
dotnet/android-libraries#1558 · 1 条评论 · 1 个 reaction · 已指派 2 人 ·
维护者通常 2 天内回复
-
难度 4/5 3-5 天 新手友好度 68/100
dotnet/android-libraries#1549 ·
维护者通常 2 天内回复
-
难度 4/5 3-5 天 新手友好度 55/100
dotnet/android-libraries#1503 ·
维护者通常 2 天内回复
查看 dotnet/android-libraries 的全部 Issue
相似的 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 70/100
lugassawan/swe-workbench#823 ·
维护者通常 1 天内回复
-
devtools
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 1 天内回复
-
clawsweeper:fix-shape-clear clawsweeper:needs-maintainer-review clawsweeper:no-new-fix-pr clawsweeper:not-repro-on-main impact:ux-release-blocker issue-rating: 🦪 silver shellfish P0
难度 2/5 1-3 小时 新手友好度 72/100
openclaw/openclaw-windows-node#1843 · 1 条评论 · 1 个 reaction ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 66/100
-
kind:ux size:S type:bug
难度 2/5 1-3 小时 新手友好度 78/100
elsa-workflows/elsa-foundation#3256 ·
维护者通常 1 天内回复