一个WP7应用中使用了Google AdMob 控件 (客户要求使用google ad,若无要求,强烈建议使用MS的 Ad控件)。下面是使用AdMob 的WP7控件遇到的问题:
1. 墙 - 国内目前无法显示ad内容。如需测试,请用vpn电脑,手机连接电脑,测试显示效果
2. 严重的crash:
使用目前最新的4.0.4版本依然有2个严重的异常:
异常1: 常在有ad的页面加载时就抛出
System.SystemException was unhandled
Message=An unknown error has occurred. Error: 80020101.
StackTrace:
at Microsoft.Phone.Controls.NativeMethods.ValidateHResult(Int32 hr)
at Microsoft.Phone.Controls.WebBrowserInterop.InvokeScript(String scriptName, String[] args)
at Microsoft.Phone.Controls.WebBrowser.InvokeScript(String scriptName, String[] args)
at Google.AdMob.Ads.WindowsPhone7.WPF.DisplayAdBase.<>c__DisplayClass36.<RunScripts>b__34()
at System.Reflection.RuntimeMethodInfo.InternalInvoke(RuntimeMethodInfo rtmi, Object obj, BindingFlags invokeAttr, Binder binder, Object parameters, CultureInfo culture, Boolean isBinderDefault, Assembly caller, Boolean verifyAccess, StackCrawlMark& stackMark)
at System.Reflection.RuntimeMethodInfo.InternalInvoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, StackCrawlMark& stackMark)
at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
at System.Delegate.DynamicInvokeOne(Object[] args)
at System.MulticastDelegate.DynamicInvokeImpl(Object[] args)
at System.Delegate.DynamicInvoke(Object[] args)
at System.Windows.Threading.DispatcherOperation.Invoke()
at System.Windows.Threading.Dispatcher.Dispatch(DispatcherPriority priority)
at System.Windows.Threading.Dispatcher.OnInvoke(Object context)
at System.Windows.Hosting.CallbackCookie.Invoke(Object[] args)
at System.Windows.Hosting.DelegateWrapper.InternalInvoke(Object[] args)
at System.Windows.RuntimeHost.ManagedHost.InvokeDelegate(IntPtr pHandle, Int32 nParamCount, ScriptParam[] pParams, ScriptParam& pResult)
异常2:少见。在离开应用,按Back键返回时偶有遇到
System.NullReferenceException was unhandled
Message=NullReferenceException
StackTrace:
at Google.AdMob.Ads.WindowsPhone7.Support.DownloadHelper.<>c__DisplayClass1.<Run>b__0(IAsyncResult AsyncResult)
at System.Net.Browser.ClientHttpWebRequest.<>c__DisplayClassa.<InvokeGetResponseCallback>b__8(Object state2)
at System.Threading.ThreadPool.WorkItem.WaitCallback_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadPool.WorkItem.doWork(Object o)
at System.Threading.Timer.ring()
解决办法:无 - 需要google 修复控件存在的问题
所谓的"workaround": 在Application_UnhandledException中处理这些异常
private
voidApplication_UnhandledException(objectsender,ApplicationUnhandledExceptionEventArgse)
{
if(e.ExceptionObject.Message=="Anunknownerrorhasoccurred.Error:80020101.")//google'sadcontrolcrash,ignorethis
{
e.Handled=true;
}
if(e.ExceptionObject.StackTrace.IndexOf("Google")>=0)
{
e.Handled=true;//ignoregoogle'sadcontrolcrash
}
else
{
#if
DEBUG
MessageBox.Show(e.ExceptionObject.ToString());
#else
MessageBox.Show("oops,anerroroccurred");
#endif
e.Handled=true;
}
if(System.Diagnostics.Debugger.IsAttached)
{
//Anunhandledexceptionhasoccurred;breakintothedebugger
System.Diagnostics.Debugger.Break();
}
}
参考:https://groups.google.com/forum/#!topic/google-admob-ads-sdk/aI_YSr0QX-I
3. 控件尺寸: 如果其他条件正常但是ad无法显示,可能是尺寸问题导致。控件尺寸应为480x75
参考:https://groups.google.com/forum/#!searchin/google-admob-ads-sdk/wp7/google-admob-ads-sdk/P8Sw_kSN-VQ/p0jwYh1JimgJ
MS ad control也有同样的尺寸要求: 480x80
4.前景/背景: ad控件前景色总是使用系统theme当前的前景色,例如在light theme中,前景色总是黑色,设置Foreground属性无效。而且该控件背景色为透明,这就意味着在light theme下如果应用的背景色较深,基本ad上的文字很难看清 - 可能导致应用审核不通过。
较好的方法是动态设置ad控件的背景:
<StackPanelWidth="480"Height="75"x:Name="adContainer">
<google:BannerAdAdReceived="BannerAd_AdReceived"
xmlns:google="clr-namespace:Google.AdMob.Ads.WindowsPhone7.WPF;assembly=Google.AdMob.Ads.WindowsPhone7"
AdUnitID=""/>
</StackPanel>
privatevoidBannerAd_AdReceived(objectsender,RoutedEventArgse)
{
//adbarforegroundalwaysusestheforegroundofphone'scurrenttheme,sosetbackgroundtomaketextreadable
adContainer.Background=App.Current.Resources["PhoneBackgroundBrush"]asBrush;
}
参考:
http://msdn.microsoft.com/en-us/library/ff769552(VS.92).aspx#BKMK_BrushResources5. 性能:此控件性能难令人满意,加载时会影响页面加载速度。
来自google的性能测试及注意:
In Emulator
------------------------------<wbr>---------------</wbr>
Initial Startup:
1 - 1.5 seconds
General UI Lagginess:
0.1 - 0.2 seconds
Ad Refreshing:
0.2 - 0.3 seconds
Removing Ad and Recreating:
0.3 - 0.4 seconds
------------------------------<wbr>---------------</wbr>
0.5- 1.0 seconds
0.02 - 0.05 seconds
0.06 - 0.10 seconds
Removing Ad and Recreating:
0.2 - 0.3 seconds
------------------------------<wbr>---------------</wbr>
This is largely due to controls that need to be loaded. These are loaded when the ad control is first put in the visual tree, regardless of IsEnabled setting.
Determined by running a DispatchTimer with an interval of one millisecond which updates the display
On the emulatorthis is usually lost in the general UI framerate
Removing Ad and Recreating:
This is not preferred as there are unwanted side effects
We use the WebBrowser control as a script engine. Unfortunately this seems to be the cause of the lag as it requires scripts be run on the UI thread (as well as the major side effect when recreating an ad - stealing input focus). We're looking for alternatives to using the WebBrowser control for scripting, but there aren't any straightforward answers.
We do recognize this and are working on it though. In the meantime, you'll get the best performance if you avoid destroying and recreating the ad control.
分享到:
相关推荐
Admob 广告SDK最新版本Admob SDK 7.32,也就是google play service 7.32.是Admob升级后的SDK最新版本。Admob常常被墙,为方便把Admob SDK 最新版本放这方便下载使用
安卓版admob sdk 最新版本9,google play service sdk中广告部分firebase sdk版本中广告部分,最新版本google 广告,admob android sdk最新版本
GoogleAdMobAdsSdk-6.4.1.jar
免费:Android平台使用-谷歌广告联盟AdMob-赚取收益的编程方法-demo - 横幅广告 - 插页广告 - 视频广告
安装您可以使用npm或Yarn安装最新的Beta版本: npm: npm i --save react-native-admob@next纱: yarn add react-native-admob@next为了使用该库,您必须首先将其链接到您的项目。 在有关于如何执行此操作的出色。 ...
admob 广告 SDK IOS
该SDK将支持: • 从代码视图中创建AdMob标识 • 直接在XAML文件中嵌入...这个SDK beta版本并没有包括在iOS和Android提供的以下功能: • 广告网络调解 • 支持双击点击广告 • 搜素支持移动应用的广告 • MRAID支持
这个demo在虚拟器上会出现,调用广告有时候会出现Cannot find an ad network adapter with the name(s): com.google.DummyAdapter. Remember to link all required ad network adapters and SDKs,但在真机上没问题,...
Admob iOS SDK 7.0.0 版,改进对iOS8的支持。•Dropped support for iOS 5. •Released SDK as a framework. •Removed dependency on the -ObjC linker flag. •Improved ad loading time on iOS 8. •Added ...
GoogleAdMobAdsSdk,广告移植进入apk中
Cordova 插件是将 Google Ads ... 适用于 WP8 的 Google AdMob SDK,v6.5.13 混淆器 如果您计划在发布您的应用之前在您的 APK 上运行 ProGuard,您需要将以下内容添加到您的 proguard.cfg 文件中: -keep class * e
admob sdk,for ios6.0,support armv7 and armv7s
AdMob_Android_SDK_Instructions.pdf
适用于Cordova的免费,无广告共享的Google AdMob插件版本。 地位 所有无cordova-plugin-admob-free都应改用进行最新改进。 一段时间以来,我一直在问有关的兴趣,得到了一些令人鼓舞的反馈,最后建立。 如果可能,...
从谷歌上下载的SDK 为了给大家省时间, 打开谷歌的网页实在太慢了
google admob ads for unity插件,同时支持android和iOS。 支持新版本admob横幅很插屏广告。 android项目把admob_unity_plugin.unitypackage import进unity3d工程即可 然后把admobdemo.cs 复制到项目中,并修改...
GoogleAdmob接入封装,androidstudio中接入admob。
将原生Admob SDK与Axway Hyperloop结合使用。 目前,此模块仅适用于Android,仅支持非页内广告。 运行样本 将titanium-admob文件夹复制到您的lib/ (合金)或您的Resources/ (经典)目录。 将示例代码复制到您的...
expo-google-admob 结合使用Google Admob和Expo来通过您的应用获利 查看克隆仓库$ git clone git@github.com:deadcoder0904/expo-google-admob.git安装依赖项$ yarn运行应用$ yarn start执照麻省理工学院:copyright:
Google Admob Ads Sdk package Google Market Billing package Google Market Licensing package Google USB Driver package Google Webdriver package 2、Android 4.0模拟器(可选装)------ android-4.0_API...