【发布时间】:2014-11-30 17:36:21
【问题描述】:
我试图使用新的 google-service-libs 在我的应用中设置 admob 广告。并且在 genymotion 模拟器广告中看起来一切都很好。但他们不在真正的设备上,比如我的带有 android 2.3.6 的 Galaxy ace gt5830i。我不知道是什么问题。
这里有一些代码:
XML:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/background"
android:orientation="vertical" >
<LinearLayout
android:id="@+id/titleBar"
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="@drawable/title_bar"
android:orientation="horizontal" >
<ImageView
android:id="@+id/iconImg"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_gravity="center"
android:layout_margin="5dip"
android:background="@drawable/app_icon" />
<ImageView
android:id="@+id/titleImg"
android:layout_width="160dp"
android:layout_height="45dp"
android:layout_gravity="center"
android:layout_margin="5dip"
android:background="@drawable/title" />
<RelativeLayout
android:id="@+id/pagerBtn"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:paddingRight="2dip" >
<ImageButton
android:id="@+id/pager"
android:layout_width="45dp"
android:layout_height="35dp"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:background="@drawable/button_clicked"
android:scaleType="fitXY"
android:src="@drawable/pager" />
</RelativeLayout>
</LinearLayout>
<View
android:layout_width="fill_parent"
android:layout_height="5dip"
android:background="@drawable/shadow" >
</View>
<com.google.android.gms.ads.AdView
android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
ads:adSize="BANNER"
ads:adUnitId="@string/adUnitId" />
<ListView
android:id="@+id/list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/buttons"
android:divider="#351802"
android:dividerHeight="2dp"
android:listSelector="@drawable/list_selector" />
</LinearLayout>
我的 Ad_Unit_Id 保存在 res/ 文件夹中的 string.xml 文件中。
java:
AdView ad = (AdView) findViewById(R.id.adView);
AdRequest req = new AdRequest.Builder().build();
ad.loadAd(req);
如果您需要更多代码,请告诉我。谢谢
【问题讨论】:
-
检查横幅的分辨率以及 AdView 上的填充。我猜 AdView 的大小是 320 x 50 dip .. 另外,检查你的 logcat
-
好的,我会检查并回复谢谢。
-
发布您的 logcat,它会告诉您为什么没有收到广告。可能很简单,因为您的设备没有可用的广告。
标签: android admob google-play-services