当前位置: 动力学知识库 > 问答 > 编程问答 >

In android 2.3 my admob advert will not show up but in android 4.0+ it shows up

问题描述:

I have an android application that I have been working on using only a nexus 4 and nexus 7 for testing but then I realized I haven't been testing on anything lower than android 4.0 so I put in my galaxy player which has android 2.3 and then I realized that my admob advert way missing from the application so I waited a minute to see if it would load but nothing is coming up. If anyone can see why it would be greatly appreciated. The XML is bellow. The error that comes up with is com.google.ads.AdView failed to instantiate this is only shown in android 2.3

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"

xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"

xmlns:tools="http://schemas.android.com/tools"

android:layout_width="match_parent"

android:layout_height="match_parent" >

<TabHost

android:id="@+id/tabhost"

android:layout_width="match_parent"

android:layout_height="match_parent"

android:layout_alignParentTop="true"

android:layout_centerHorizontal="true" >

<RelativeLayout

android:layout_width="match_parent"

android:layout_height="match_parent"

android:orientation="vertical" >

<TabWidget

android:id="@android:id/tabs"

android:layout_width="match_parent"

android:layout_height="wrap_content" >

</TabWidget>

<FrameLayout

android:id="@android:id/tabcontent"

android:layout_width="match_parent"

android:layout_height="match_parent" >

<RelativeLayout

android:id="@+id/tab1"

android:layout_width="match_parent"

android:layout_height="match_parent" >

<TextView

android:id="@+id/tvDistance"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_alignParentLeft="true"

android:layout_marginTop="64dp"

android:layout_marginLeft="24dp"

android:text="@string/distance" />

<EditText

android:id="@+id/etDistance"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_alignLeft="@+id/tvDistance"

android:layout_alignParentRight="true"

android:layout_below="@+id/tvDistance"

android:layout_marginRight="24dp"

android:layout_marginTop="8dp"

android:ems="10"

android:hint="@string/dis"

android:inputType="numberDecimal" >

<requestFocus

android:layout_width="wrap_content"

android:layout_height="match_parent" />

</EditText>

<TextView

android:id="@+id/tvFuel"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_alignLeft="@+id/etDistance"

android:layout_below="@+id/etDistance"

android:layout_marginTop="8dp"

android:text="@string/litres" />

<EditText

android:id="@+id/etFuel"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_alignLeft="@+id/tvFuel"

android:layout_below="@+id/tvFuel"

android:layout_marginTop="8dp"

android:layout_alignParentRight="true"

android:layout_marginRight="24dp"

android:hint="@string/lit"

android:inputType="numberDecimal" />

<Button

android:id="@+id/btCalc"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_alignLeft="@+id/etFuel"

android:layout_below="@+id/etFuel"

android:layout_marginTop="8dp"

android:text="@string/calculate" />

<TextView

android:id="@+id/tvMPG"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_alignLeft="@+id/btCalc"

android:layout_below="@+id/btCalc"

android:layout_marginTop="8dp"

android:text="@string/mpg" />

<EditText

android:id="@+id/etMPG"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_alignLeft="@+id/tvMPG"

android:layout_below="@+id/tvMPG"

android:layout_marginTop="8dp"

android:layout_alignParentRight="true"

android:layout_marginRight="24dp"

android:ems="10"

android:clickable="false"

android:focusable="false"

android:inputType="numberDecimal" />

</RelativeLayout>

<RelativeLayout

android:id="@+id/tab2"

android:layout_width="match_parent"

android:layout_height="match_parent" >

<TextView

android:id="@+id/tvPrice"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_alignParentLeft="true"

android:layout_marginTop="64dp"

android:layout_marginLeft="24dp"

android:text="@string/price" />

<EditText

android:id="@+id/etPrice"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_alignLeft="@+id/tvPrice"

android:layout_alignParentRight="true"

android:layout_below="@+id/tvPrice"

android:layout_marginRight="24dp"

android:layout_marginTop="8dp"

android:ems="10"

android:hint="@string/pri"

android:inputType="numberDecimal" >

<requestFocus

android:layout_width="wrap_content"

android:layout_height="match_parent" />

</EditText>

<TextView

android:id="@+id/tvFuelIn"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_alignLeft="@+id/tvPrice"

android:layout_below="@+id/etPrice"

android:layout_marginTop="8dp"

android:text="@string/fuel" />

<EditText

android:id="@+id/etFuelIn"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_alignLeft="@+id/tvPrice"

android:layout_below="@+id/tvFuelIn"

android:layout_marginTop="8dp"

android:layout_alignParentRight="true"

android:layout_marginRight="24dp"

android:hint="@string/fu"

android:inputType="numberDecimal" />

<Button

android:id="@+id/btCalc2"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_alignLeft="@+id/tvPrice"

android:layout_below="@+id/etFuelIn"

android:layout_marginTop="8dp"

android:text="@string/calculate" />

<TextView

android:id="@+id/tvLitres"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_alignLeft="@+id/tvPrice"

android:layout_below="@+id/btCalc2"

android:layout_marginTop="8dp"

android:text="@string/Nolitres" />

<EditText

android:id="@+id/etLitres"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_alignLeft="@+id/tvPrice"

android:layout_below="@+id/tvLitres"

android:layout_marginTop="8dp"

android:layout_alignParentRight="true"

android:layout_marginRight="24dp"

android:ems="10"

android:clickable="false"

android:focusable="false"

android:inputType="numberDecimal" />

</RelativeLayout>

</FrameLayout>

</RelativeLayout>

</TabHost>

<com.google.ads.AdView

android:id="@+id/advert"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_alignParentBottom="true"

android:layout_centerInParent="true"

ads:adSize="SMART_BANNER"

ads:adUnitId="a150bb48a445a2f"

ads:loadAdOnCreate="true" >

</com.google.ads.AdView>

</RelativeLayout>

分享给朋友:
您可能感兴趣的文章:
随机阅读: