谷歌的广告显示空白,你有什么建议? [英] google ad displays blank, what do you suggest?
问题描述
您好我能够加入谷歌AdMob的旗帜,它显示的元数据的错误信息,当我跑的应用程序它的自我,但一旦我还是设法解决这些问题,它并没有显示谷歌广告。它显示横幅但它是空的。
予有它设置使得AD浏览是在不同的布局的背景,它显示了当屏幕被窃听。问题是,当你点击屏幕就显示了一个横幅较暗的区域,正在显示的标题错误的地方(我假设是GoogleAd横幅),但它显示为空。所以它只是区域变暗,但显示没有。
下面是我的MigratorisActivity.java
保护无效的onCreate(包savedInstanceState){
super.onCreate(savedInstanceState);
的setContentView(R.layout.migratoris_activity);
最后查看controlsView = findViewById(R.id.fullscreen_content_controls);
最后查看内容查看= findViewById(R.id.GIFSingle);
//创建AD浏览报。
AD浏览报=新的AD浏览报(本);
adView.setAdUnitId(一个--------------);
adView.setAdSize(AdSize.BANNER);
//查找您的LinearLayout假设它是被赋予了
//属性机器人:ID =@ + ID / mainLayout。
的LinearLayout布局=(的LinearLayout)findViewById(R.id.fullscreen_content_controls);
// AD浏览报添加到它。
layout.addView(AD浏览报);
//初始化一个通用的请求。
AdRequest adRequest =新AdRequest.Builder()建立()。
//加载的广告请求AD浏览报。
adView.loadAd(adRequest);
这是我的清单:
<使用-SDK
安卓的minSdkVersion =8
机器人:targetSdkVersion =17/>
<应用
机器人:allowBackup =真
机器人:图标=@可绘制/ ic_launcher
机器人:标签=@字符串/ APP_NAME
机器人:主题=@风格/ AppTheme>
<元数据的android:NAME =com.google.android.gms.version
机器人:值=@整数/ google_play_services_version/>
<活动
机器人:名称=pt.quintas.migratoris.MigratorisActivity
机器人:configChanges =定位| keyboardHidden |屏幕尺寸
机器人:标签=@字符串/ APP_NAME
机器人:主题=@风格/ FullscreenTheme>
<意向滤光器>
<作用机器人:名称=android.intent.action.MAIN/>
<类机器人:名称=android.intent.category.LAUNCHER/>
&所述; /意图滤光器>
< /活性GT;
<活动机器人:名称=com.google.android.gms.ads.AdActivity
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
< /用途>
<使用-权限的Android:名称=android.permission.INTERNET对/>
<使用-权限的Android:名称=android.permission.ACCESS_NETWORK_STATE/>
< /舱单>
任何人都有一个想法,为什么它显示,但没有广告?会不会是我有AdMob的帐户设置为测试模式?
感谢您对我付出的时间, 佩德罗
下面是布局
<的FrameLayout
的xmlns:机器人=http://schemas.android.com/apk/res/android
的xmlns:工具=http://schemas.android.com/tools
机器人:layout_width =match_parent
机器人:layout_height =match_parent
机器人:后台=#000000
机器人:ID =@ + ID / MainLayout
工具:上下文=MigratorisActivity。>
<! -
主要的全屏视图。这可以替换为任何视图
是需要present您的内容,例如VideoView,SurfaceView,
TextureView等。
- >
< pt.quintas.migratoris.GIFView
机器人:layout_marginLeft =0dp
机器人:layout_gravity =中心
机器人:layout_width =FILL_PARENT
机器人:layout_height =FILL_PARENT
机器人:ID =@ + ID / GIFSingle>
< /pt.quintas.migratoris.GIFView>
<的TextView
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_marginBottom =20dip
机器人:layout_gravity =center_horizontal |顶
机器人:TEXTSTYLE =黑体
机器人:TEXTSIZE =10PT
机器人:填充=16dip
机器人:文字颜色=#FFFFFFFF
机器人:文本=您已经迁移了:/>
<的TextView
机器人:ID =@ + ID / textCounter
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_marginBottom =20dip
机器人:layout_gravity =center_horizontal |底
机器人:TEXTSTYLE =黑体
机器人:TEXTSIZE =10PT
机器人:填充=16dip
机器人:文字颜色=#FFFFFFFF
机器人:文本=/>
<! -
基于使用的系统窗口此的FrameLayout镶石其子
机器人:fitsSystemWindows。
- >
<的FrameLayout
机器人:layout_width =match_parent
机器人:layout_height =match_parent
机器人:fitsSystemWindows =真正的>
<的LinearLayout
机器人:ID =@ + ID / fullscreen_content_controls
风格=?buttonBarStyle
机器人:layout_width =match_parent
机器人:layout_height =WRAP_CONTENT
机器人:layout_gravity =底部| center_horizontal
机器人:背景=@色/ black_overlay
机器人:方向=横向
工具:忽略=UselessParent>
< / LinearLayout中>
< /的FrameLayout>
< /的FrameLayout>
我试图让在MainLayout的附加工作,它的工作,我相信这个问题是与布局的膨胀,它需要更多的空间。 这里是LOGG:
01-15 16:50:53.552:I / ApplicationPackageManager(11135):cscCountry是不是德国:VOD
01-15 16:50:54.002:I /广告(11135):使用AdRequest.Builder.addTestDevice(B246DEAA33A5FAE6AF9FF0A2F44B5CBC),以获得在该设备上测试广告。
01-15 16:50:54.002:I /广告(11135):启动广告请求。
01-15 16:50:54.002:I / webclipboard(11135):clipservice:android.sec.clipboard.ClipboardExManager@4065d018
01-15 16:50:54.012:W /广告(11135):没有足够的空间来显示广告。需要480x75,但只具有474x754
01-15 16:50:54.022:W /广告(11135):没有足够的空间来显示广告。需要480x75,但只具有474x792
01-15 16:50:54.032:W /广告(11135):没有足够的空间来显示广告。需要480x75,但只具有474x792
01-15 16:50:54.052:E / GooglePlayServicesUtil(11135):在谷歌播放均未发现服务的资源。检查项目配置,以确保资源被包括在内。
01-15 16:50:54.182:E / GooglePlayServicesUtil(11135):在谷歌播放均未发现服务的资源。检查项目配置,以确保资源被包括在内。
01-15 16:50:54.223:E /(11135):表情AGIF错误7 700 100 7
01-15 16:50:54.273:E / GooglePlayServicesUtil(11135):在谷歌播放均未发现服务的资源。检查项目配置,以确保资源被包括在内。
01-15 16:50:54.443:E /(11135):表情AGIF错误7 700 100 7
01-15 16:50:54.663:E /(11135):表情AGIF错误7 700 100 7
01-15 16:50:54.893:E /(11135):表情AGIF错误7 700 100 7
01-15 16:50:55.183:E /(11135):表情AGIF错误7 700 100 7
01-15 16:50:55.384:E /(11135):表情AGIF错误7 700 100 7
01-15 16:50:55.584:E /(11135):表情AGIF错误7 700 100 7
01-15 16:50:55.804:E /(11135):表情AGIF错误7 700 100 7
01-15 16:50:56.134:E /(11135):表情AGIF错误7 700 100 7
01-15 16:50:56.224:I /广告(11135):广告加载完毕。
您缺少com.google.ads.AdView在XML文件中,请尝试以下操作:
< com.google.ads.AdView
机器人:ID =@ + ID / AD浏览报
机器人:layout_width =FILL_PARENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_alignParentBottom =真
广告:adSize =SMART_BANNER
广告:adUnitId =YOUR_ID
广告:的refreshInterval =NUMBER_UP_TO_YOU>
< /com.google.ads.AdView>
让我知道,如果这可以帮助你或没有。
Hi I was able to add the google adMob banner, and it displayed the error messages of the meta-data, when I ran the app it self, but once I did manage to solve those problems it does not show the google ad. It shows the banner however it is empty.
I have it set so that the adView is in a different layout to the background, and it shows when the screen is tapped. The problem is that when you tap the screen it shows a banner darker area, where the banner errors were being displayed (which I assume to be the GoogleAd banner) however it shows empty. So only the area of it is darkened but displaying nothing.
Here is my MigratorisActivity.java
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.migratoris_activity);
final View controlsView = findViewById(R.id.fullscreen_content_controls);
final View contentView = findViewById(R.id.GIFSingle);
// Create the adView.
adView = new AdView(this);
adView.setAdUnitId("a--------------");
adView.setAdSize(AdSize.BANNER);
// Lookup your LinearLayout assuming it's been given
// the attribute android:id="@+id/mainLayout".
LinearLayout layout = (LinearLayout) findViewById(R.id.fullscreen_content_controls);
// Add the adView to it.
layout.addView(adView);
// Initiate a generic request.
AdRequest adRequest = new AdRequest.Builder().build();
// Load the adView with the ad request.
adView.loadAd(adRequest);
This is my Manifest:
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<meta-data android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version"/>
<activity
android:name="pt.quintas.migratoris.MigratorisActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:label="@string/app_name"
android:theme="@style/FullscreenTheme" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.google.android.gms.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
</application>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
</manifest>
Anyone have an idea why it shows but without an ad? could it be that I have the AdMob account set to test mode?
Thank you very much for your time, Pedro
Here is the Layout
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#000000"
android:id="@+id/MainLayout"
tools:context=".MigratorisActivity" >
<!--
The primary full-screen view. This can be replaced with whatever view
is needed to present your content, e.g. VideoView, SurfaceView,
TextureView, etc.
-->
<pt.quintas.migratoris.GIFView
android:layout_marginLeft="0dp"
android:layout_gravity="center"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/GIFSingle">
</pt.quintas.migratoris.GIFView>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="20dip"
android:layout_gravity="center_horizontal|top"
android:textStyle="bold"
android:textSize="10pt"
android:padding="16dip"
android:textColor="#ffffffff"
android:text="You have migrated for:" />
<TextView
android:id="@+id/textCounter"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="20dip"
android:layout_gravity="center_horizontal|bottom"
android:textStyle="bold"
android:textSize="10pt"
android:padding="16dip"
android:textColor="#ffffffff"
android:text="" />
<!--
This FrameLayout insets its children based on system windows using
android:fitsSystemWindows.
-->
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true" >
<LinearLayout
android:id="@+id/fullscreen_content_controls"
style="?buttonBarStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom|center_horizontal"
android:background="@color/black_overlay"
android:orientation="horizontal"
tools:ignore="UselessParent" >
</LinearLayout>
</FrameLayout>
</FrameLayout>
I have tried to make the add work in the MainLayout and it worked I believe the problem is inflating it with the layout, it needs more space. here is the logg:
01-15 16:50:53.552: I/ApplicationPackageManager(11135): cscCountry is not German : VOD
01-15 16:50:54.002: I/Ads(11135): Use AdRequest.Builder.addTestDevice("B246DEAA33A5FAE6AF9FF0A2F44B5CBC") to get test ads on this device.
01-15 16:50:54.002: I/Ads(11135): Starting ad request.
01-15 16:50:54.002: I/webclipboard(11135): clipservice: android.sec.clipboard.ClipboardExManager@4065d018
01-15 16:50:54.012: W/Ads(11135): Not enough space to show ad. Needs 480x75, but only has 474x754
01-15 16:50:54.022: W/Ads(11135): Not enough space to show ad. Needs 480x75, but only has 474x792
01-15 16:50:54.032: W/Ads(11135): Not enough space to show ad. Needs 480x75, but only has 474x792
01-15 16:50:54.052: E/GooglePlayServicesUtil(11135): The Google Play services resources were not found. Check your project configuration to ensure that the resources are included.
01-15 16:50:54.182: E/GooglePlayServicesUtil(11135): The Google Play services resources were not found. Check your project configuration to ensure that the resources are included.
01-15 16:50:54.223: E/(11135): Wink AGIF Error 7 700 100 7
01-15 16:50:54.273: E/GooglePlayServicesUtil(11135): The Google Play services resources were not found. Check your project configuration to ensure that the resources are included.
01-15 16:50:54.443: E/(11135): Wink AGIF Error 7 700 100 7
01-15 16:50:54.663: E/(11135): Wink AGIF Error 7 700 100 7
01-15 16:50:54.893: E/(11135): Wink AGIF Error 7 700 100 7
01-15 16:50:55.183: E/(11135): Wink AGIF Error 7 700 100 7
01-15 16:50:55.384: E/(11135): Wink AGIF Error 7 700 100 7
01-15 16:50:55.584: E/(11135): Wink AGIF Error 7 700 100 7
01-15 16:50:55.804: E/(11135): Wink AGIF Error 7 700 100 7
01-15 16:50:56.134: E/(11135): Wink AGIF Error 7 700 100 7
01-15 16:50:56.224: I/Ads(11135): Ad finished loading.
You are missing the com.google.ads.AdView in your XML file, try the following:
<com.google.ads.AdView
android:id="@+id/adView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
ads:adSize="SMART_BANNER"
ads:adUnitId="YOUR_ID"
ads:refreshInterval="NUMBER_UP_TO_YOU" >
</com.google.ads.AdView>
Let me know if this helps you or not.
这篇关于谷歌的广告显示空白,你有什么建议?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!