問題描述
在帶有 Android 的 Xamarin Studio 上使用 AdMob,Google Play 服務不存在 (Use AdMob on Xamarin Studio with Android, Google Play Services don't exist)
我最近嘗試在我的 Xamarin Android 應用程序上使用 Google AdMob。但是,我一直未能成功。首先,我無法遵循教程,(例如,這個:https://blog.tommyparnell.com/admob‑with‑xamarin‑part‑1‑banner‑ads/),這裡是說去“獲取更多組件”(我我正在使用 Xamarin Studio)並下載 Google Play 服務(Jellybean)。但是,我找不到它,而是找到了很多 Google Play 服務組件。我試圖安裝一個名為:“Google Play Services ‑ Ads”(我想這個是與 Admobs 相關的)。但是,似乎有些東西不起作用,
Some required packages are not referenced by the project
我很絕望,真的不知道該怎麼做。我能做些什麼?另請注意,我擁有最新版本的 SDK。可能是這個問題嗎?如果是這樣,我該如何解決這個問題?
提前致謝
參考解法
方法 1:
That tutorial that you referred to is out‑dated and is using the deprecated version of the "Xamarin Google Play Services ‑ All" package.
You want the individual "Ads" package that will provide the ADMob
namespace (using ADMob;
) that will also install the related Play Service dependencies and you have to update the code accordingly from the tutorial to match the new Ads namespace/api. The overall code and process presented for showing ads is valid.
Open the Package Manager and search for "Xamarin Google Play Services Ads"
>Install‑Package Xamarin.GooglePlayServices.Ads ‑Version 27.0.0
Nuget Page:
https://www.nuget.org/packages/Xamarin.GooglePlayServices.Ads/27.0.0
Latest Beta Version:
https://www.nuget.org/packages/Xamarin.GooglePlayServices.Ads/28.0.0‑beta1
The 'Xamarin Google Play Services ‑ All' nuget package is now deprecated.
You should instead use the individual NuGet packages to get only the bindings you need in your application.
You can find the individual packages by searching for 'xamarin google play services': https://www.nuget.org/packages?q=xamarin+google+play+services
(by cilindr0、SushiHangover)