I try to add an admob banner. It works good on all devices with big screensize, but when I try to run it on device with a small screen resolution, the ad doesn't appear.
In logcat I see:
I/GMPM﹕ App measurement is starting up
E/GMPM﹕ getGoogleAppId failed with status: 10
E/GMPM﹕ Uploading is not possible. App measurement disabled
and
W/GooglePlayServicesUtil﹕ Google Play services out of date. Requires 8115000 but found 6599034
E/GooglePlayServicesUtil﹕ GooglePlayServices not available due to error 2
and
W/Ads﹕ Not enough space to show ad. Needs 320x50 dp, but only has 288x420 dp.
Here is main.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:background="@drawable/gradient"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.nesususu.nes.app.onResume">
<LinearLayout
android:id="@+id/linearLayout20"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentEnd="false"
android:layout_alignParentRight="false"
android:layout_alignParentTop="true"
android:gravity="top|center_horizontal"
android:nestedScrollingEnabled="false"
android:orientation="vertical">
<TextView
android:id="@+id/timeField2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_gravity="top|center_horizontal"
android:layout_marginBottom="73dp"
android:gravity="center"
android:maxLines="1"
android:padding="12dp"
android:shadowColor="@color/bright_foreground_disabled_material_dark"
android:shadowDx="0"
android:shadowDy="0"
android:shadowRadius="24"
android:text="00:00:00"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#06ff00"
android:textSize="40sp"
android:textStyle="normal|bold"
android:theme="@style/Animation.AppCompat.DropDownUp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="86dp"
android:layout_above="@+id/linearLayout16"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:gravity="center"
android:orientation="horizontal">
<Button
android:id="@+id/btnExit"
android:layout_width="91dp"
android:layout_height="86dp"
android:layout_margin="1dp"
android:background="@drawable/btnexitcode"
android:gravity="center" />
</LinearLayout>
<LinearLayout
android:id="@+id/linearLayout16"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:orientation="horizontal">
<com.google.android.gms.ads.AdView
android:id="@+id/adView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_below="@+id/linearLayout16"
android:layout_centerHorizontal="true"
android:layout_weight="1"
ads:adSize="BANNER"
ads:adUnitId="@string/banner_ad_unit_id"></com.google.android.gms.ads.AdView>
</LinearLayout>
</RelativeLayout>
build app
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId 'com.nesususu.nes.app'
minSdkVersion 15
targetSdkVersion 22
versionCode 3
versionName "1.2"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:22.2.1'
compile 'com.google.android.gms:play-services:8.1.0'
}
I tried to move the ad to relative layout, to hardcode the width, but the result is the same. Devices I tested are Xperia acro S and Samsung Galaxy tab E, both work good. But some phones like Samsung SM-G360H, won't show the ad. The resolution of last one is 480 x 800, so it should have enough space.