Xamarin Android Admob 测试广告仅在设备上显示一次

Posted

技术标签:

【中文标题】Xamarin Android Admob 测试广告仅在设备上显示一次【英文标题】:Xamarin Android Admob Test Ads only show once on a device 【发布时间】:2020-07-10 10:12:18 【问题描述】:

我开发了一个 Xamarin 表单应用程序,我最近想合并 Admob 广告并使用 this 教程。 ios 版本运行完美,而 android 版本仅在新的模拟器(格式化)上显示一次测试广告,并且再也不会出现。当我创建一个新的模拟器时,我只在第一次部署时看到广告,随后重新运行应用程序时广告不再显示。我的 Admob 帐户似乎没有任何问题。

我使用的教程相当老,所以我不得不在 Android 清单上添加这个 sn-p:

        <application android:label="MyApp">
             <meta-data android:name="com.google.android.gms.ads.APPLICATION_ID" android:value="my admob app id ~" />
             ....
        </application>

当广告未展示时,应用程序的日志如下所示。我尝试上网没有运气,可能是什么问题?非常感谢您的帮助

07-10 11:55:26.256 D/DynamitePackage( 4834): Instantiating com.google.android.gms.ads.ChimeraAdManagerCreatorImpl
07-10 11:55:26.261 I/Ads     ( 4834): This request is sent from a test device.
07-10 11:55:26.318 I/DynamiteModule( 4834): Considering local module com.google.android.gms.ads.dynamite:0 and remote module com.google.android.gms.ads.dynamite:21001
07-10 11:55:26.318 I/DynamiteModule( 4834): Selected remote version of com.google.android.gms.ads.dynamite, version >= 21001
07-10 11:55:27.069 W/Ads     ( 4834): JS: A cookie associated with a resource at http://doubleclick.net/ was set with `SameSite=None` but without `Secure`. A future release of Chrome will only deliver cookies marked `SameSite=None` if they are also marked `Secure`. You can review cookies in developer tools under Application>Storage>Cookies and see more details at https://www.chromestatus.com/feature/5633521622188032. (https://googleads.g.doubleclick.net/mads/static/mad/sdk/native/production/sdk-core-v40-impl.html:0)[INFO:CONSOLE(0)] "A cookie associated with a resource at http://doubleclick.net/ was set with `SameSite=None` but without `Secure`. A future release of Chrome will only deliver cookies marked `SameSite=None` if they are also marked `Secure`. You can review cookies in developer tools under Application>Storage>Cookies and see more details at https://www.chromestatus.com/feature/5633521622188032.", source: https://googleads.g.doubleclick.net/mads/static/mad/sdk/native/production/sdk-core-v40-impl.html (0)

07-10 11:55:27.069 I/chromium( 4834): [INFO:CONSOLE(0)] "A cookie associated with a resource at http://doubleclick.net/ was set with `SameSite=None` but without `Secure`. A future release of Chrome will only deliver cookies marked `SameSite=None` if they are also marked `Secure`. You can review cookies in developer tools under Application>Storage>Cookies and see more details at https://www.chromestatus.com/feature/5633521622188032.", source: https://googleads.g.doubleclick.net/mads/static/mad/sdk/native/production/sdk-core-v40-impl.html (0)
07-10 11:55:27.707 I/art     ( 4834): Background sticky concurrent mark sweep GC freed 2254(133KB) AllocSpace objects, 0(0B) LOS objects, 1% free, 12MB/12MB, paused 7.259ms total 26.738ms
07-10 11:55:27.789 I/art     ( 4834): Background sticky concurrent mark sweep GC freed 481(35KB) AllocSpace objects, 3(220KB) LOS objects, 0% free, 12MB/12MB, paused 56.403ms total 65.828ms
07-10 11:55:28.177 I/DynamiteModule( 4834): Considering local module com.google.android.gms.ads.dynamite:0 and remote module com.google.android.gms.ads.dynamite:21001
07-10 11:55:28.177 I/DynamiteModule( 4834): Selected remote version of com.google.android.gms.ads.dynamite, version >= 21001
[0:] 
Ad just loaded = (this point is the OnLoaded() listerner event)
07-10 11:55:28.225 E/chromium( 4834): [ERROR:tile_manager.cc(779)] WARNING: tile memory limits exceeded, some content may not draw[ERROR:tile_manager.cc(779)] WARNING: tile memory limits exceeded, some content may not draw

[ERROR:tile_manager.cc(779)] WARNING: tile memory limits exceeded, some content may not draw
07-10 11:55:28.226 E/chromium( 4834): [ERROR:tile_manager.cc(779)] WARNING: tile memory limits exceeded, some content may not draw
[ERROR:tile_manager.cc(779)] WARNING: tile memory limits exceeded, some content may not draw07-10 11:55:28.336 E/chromium( 4834): [ERROR:tile_manager.cc(779)] WARNING: tile memory limits exceeded, some content may not draw
[ERROR:tile_manager.cc(779)] WARNING: tile memory limits exceeded, some content may not draw

07-10 11:55:28.337 E/chromium( 4834): [ERROR:tile_manager.cc(779)] WARNING: tile memory limits exceeded, some content may not draw

来自单独运行的另一个日志:

07-10 12:02:22.996 D/DynamitePackage( 5094): Instantiating com.google.android.gms.ads.ChimeraAdManagerCreatorImpl
07-10 12:02:23.001 I/Ads     ( 5094): This request is sent from a test device.
07-10 12:02:23.039 I/DynamiteModule( 5094): Considering local module com.google.android.gms.ads.dynamite:0 and remote module com.google.android.gms.ads.dynamite:21001
07-10 12:02:23.039 I/DynamiteModule( 5094): Selected remote version of com.google.android.gms.ads.dynamite, version >= 21001
[INFO:CONSOLE(0)] "A cookie associated with a resource at http://doubleclick.net/ was set with `SameSite=None` but without `Secure`. A future release of Chrome will only deliver cookies marked `SameSite=None` if they are also marked `Secure`. You can review cookies in developer tools under Application>Storage>Cookies and see more details at https://www.chromestatus.com/feature/5633521622188032.", source: https://googleads.g.doubleclick.net/mads/static/mad/sdk/native/production/sdk-core-v40-impl.html (0)
07-10 12:02:23.798 W/Ads     ( 5094): JS: A cookie associated with a resource at http://doubleclick.net/ was set with `SameSite=None` but without `Secure`. A future release of Chrome will only deliver cookies marked `SameSite=None` if they are also marked `Secure`. You can review cookies in developer tools under Application>Storage>Cookies and see more details at https://www.chromestatus.com/feature/5633521622188032. (https://googleads.g.doubleclick.net/mads/static/mad/sdk/native/production/sdk-core-v40-impl.html:0)
07-10 12:02:23.798 I/chromium( 5094): [INFO:CONSOLE(0)] "A cookie associated with a resource at http://doubleclick.net/ was set with `SameSite=None` but without `Secure`. A future release of Chrome will only deliver cookies marked `SameSite=None` if they are also marked `Secure`. You can review cookies in developer tools under Application>Storage>Cookies and see more details at https://www.chromestatus.com/feature/5633521622188032.", source: https://googleads.g.doubleclick.net/mads/static/mad/sdk/native/production/sdk-core-v40-impl.html (0)
07-10 12:02:24.374 I/art     ( 5094): Background sticky concurrent mark sweep GC freed 415(25KB) AllocSpace objects, 0(0B) LOS objects, 1% free, 12MB/12MB, paused 6.902ms total 15.970ms
07-10 12:02:24.959 I/DynamiteModule( 5094): Considering local module com.google.android.gms.ads.dynamite:0 and remote module com.google.android.gms.ads.dynamite:21001
07-10 12:02:24.959 I/DynamiteModule( 5094): Selected remote version of com.google.android.gms.ads.dynamite, version >= 21001
[0:] 
Ad just loaded = (this point is the OnLoaded() listerner event)
[ERROR:tile_manager.cc(779)] WARNING: tile memory limits exceeded, some content may not draw
07-10 12:02:25.023 E/chromium( 5094): [ERROR:tile_manager.cc(779)] WARNING: tile memory limits exceeded, some content may not draw[ERROR:tile_manager.cc(779)] WARNING: tile memory limits exceeded, some content may not draw

07-10 12:02:25.024 E/chromium( 5094): [ERROR:tile_manager.cc(779)] WARNING: tile memory limits exceeded, some content may not draw
[ERROR:tile_manager.cc(779)] WARNING: tile memory limits exceeded, some content may not draw07-10 12:02:25.143 E/chromium( 5094): [ERROR:tile_manager.cc(779)] WARNING: tile memory limits exceeded, some content may not draw

[ERROR:tile_manager.cc(779)] WARNING: tile memory limits exceeded, some content may not draw07-10 12:02:25.144 E/chromium( 5094): [ERROR:tile_manager.cc(779)] WARNING: tile memory limits exceeded, some content may not draw

07-10 12:03:35.001 I/Ads     ( 5094): This request is sent from a test device.
07-10 12:03:35.944 I/DynamiteModule( 5094): Considering local module com.google.android.gms.ads.dynamite:0 and remote module com.google.android.gms.ads.dynamite:21001
07-10 12:03:35.944 I/DynamiteModule( 5094): Selected remote version of com.google.android.gms.ads.dynamite, version >= 21001
07-10 12:03:35.962 W/Ads     ( 5094): #004 The webview is destroyed. Ignoring action.
07-10 12:03:35.965 W/Ads     ( 5094): #004 The webview is destroyed. Ignoring action.
07-10 12:03:35.966 W/Ads     ( 5094): #004 The webview is destroyed. Ignoring action.
[0:] 
Ad just loaded
07-10 12:03:35.992 W/Ads     ( 5094): #004 The webview is destroyed. Ignoring action.
07-10 12:03:35.994 W/Ads     ( 5094): #004 The webview is destroyed. Ignoring action.
07-10 12:03:36.478 E/chromium( 5094): [ERROR:tile_manager.cc(779)] WARNING: tile memory limits exceeded, some content may not draw[ERROR:tile_manager.cc(779)] WARNING: tile memory limits exceeded, some content may not draw

[ERROR:tile_manager.cc(779)] WARNING: tile memory limits exceeded, some content may not draw07-10 12:03:36.480 E/chromium( 5094): [ERROR:tile_manager.cc(779)] WARNING: tile memory limits exceeded, some content may not draw

[ERROR:tile_manager.cc(779)] WARNING: tile memory limits exceeded, some content may not draw07-10 12:03:36.586 E/chromium( 5094): [ERROR:tile_manager.cc(779)] WARNING: tile memory limits exceeded, some content may not draw

07-10 12:03:36.587 E/chromium( 5094): [ERROR:tile_manager.cc(779)] WARNING: tile memory limits exceeded, some content may not draw
[ERROR:tile_manager.cc(779)] WARNING: tile memory limits exceeded, some content may not draw

【问题讨论】:

【参考方案1】:

我遇到了完全相同的问题,现在已经解决了。

首先: 1- 推荐你使用这个 nuget 包: https://github.com/marcojak/TestMTAdmob

2- Thr 广告仅显示一次,因为您没有尺寸。我用这段代码解决了这个问题:

<admob:MTAdView x:Name="myAds" IsVisible="true" PersonalizedAds="true" AdsId="ca-app-pub-3940256099942544/6300978111" VerticalOptions="EndAndExpand" >
                <admob:MTAdView.HeightRequest>
                    <x:OnIdiom>
                        <x:OnIdiom.Phone>50</x:OnIdiom.Phone>
                        <x:OnIdiom.Tablet>90</x:OnIdiom.Tablet>
                        <x:OnIdiom.Desktop>90</x:OnIdiom.Desktop>
                    </x:OnIdiom>
                </admob:MTAdView.HeightRequest>
            </admob:MTAdView>

【讨论】:

以上是关于Xamarin Android Admob 测试广告仅在设备上显示一次的主要内容,如果未能解决你的问题,请参考以下文章

在 Xamarin 表单中使用 Facebook Audience Network 进行 AdMob 中介

admob 广告未在 flash 中使用 milkmangames 扩展显示

admob 广告未在 flash 中使用 milkmangames 扩展显示

尝试放置 AdMob 后未找到 Xamarin.iOS Runtime.cs

使用 Admob SDK 版本 6.12.0 的 Xamarin iOS 应用程序上的 Admob 问题

Admob 测试广告不起作用,只有真实的广告在显示 - Android