com.google.ads.AdView未能实例化布局问题 [英] com.google.ads.AdView failed to instantiate layout issue
问题描述
我有问题的AdMob广告集成与我的布局。在布局我有地图片段的线性和相对布局。我想,我的广告通过在我的应用程序的顶部或底部。我的布局文件看起来是这样的:
I've got problem with integrate admob ad with my layout. In layout I have map fragment linear and relative layouts. I'd like that my ad by at the top or bottom of my app. My layout file looks like this:
<com.google.ads.AdView
android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
ads:adSize="BANNER"
ads:adUnitId="xxx"
ads:loadAdOnCreate="true"
android:layout_centerHorizontal="true"/>
<RelativeLayout
android:id="@+id/searchTextLayout"
android:layout_width="match_parent"
android:layout_height="50dip"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginBottom="20dip"
android:layout_marginLeft="10dip"
android:layout_marginRight="10dip"
android:layout_marginTop="1dip"
android:orientation="horizontal" >
<ImageButton
android:id="@+id/button1"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_alignParentBottom="true"
android:background="@null"
android:onClick="geoLocate"
android:scaleType="fitCenter"
android:src="@drawable/but" />
<EditText
android:id="@+id/editText1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_toRightOf="@id/button1"
android:background="@drawable/sback"
android:hint="Wprowadź swój adres"
android:padding="8dp"
android:textColor="@android:color/black" />
</RelativeLayout>
<fragment
android:id="@+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="fill_parent" />
当我选择图形布局我已经得到了这个错误:
and when i choose graphical layout i've got this error:
The following classes could not be instantiated:
- com.google.ads.AdView (Open Class, Show Error Log)
See the Error Log (Window > Show View) for more details.
java.lang.NoSuchMethodError: com.google.ads.AdSize.createAdSize(Lcom/google/ads/AdSize;Landroid/content/Context;)Lcom/google/ads/AdSize;
at com.google.ads.AdView.a(SourceFile:161)
at com.google.ads.AdView.a(SourceFile:352)
at com.google.ads.AdView.<init>(SourceFile:125)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0( at sun.reflect.NativeConstructorAccessorImpl.newInstance( at sun.reflect.DelegatingConstructorAccessorImpl.newInstance( at java.lang.reflect.Constructor.newInstance( at com.android.ide.eclipse.adt.internal.editors.layout.ProjectCallback.instantiateClass(ProjectCallback.java:422)
at com.android.ide.eclipse.adt.internal.editors.layout.ProjectCallback.loadView(ProjectCallback.java:179)
at android.view.BridgeInflater.loadCustomView(BridgeInflater.java:207)
at android.view.BridgeInflater.createViewFromTag(BridgeInflater.java:135)
at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:746)
at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:64)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:718)
at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
at android.view.LayoutInflater.inflate(LayoutInflater.java:372)
有人可以帮我解决这个问题? PLZ
Can somebody help my solve this problem? PLZ
推荐答案
这是几乎可以肯定是同一问题的<一个href="http://stackoverflow.com/questions/10447822/com-google-ads-adview-failed-to-instantiate">com.google.ads.AdView未能实例化。特别是退房的屏幕尺寸Eric的评论。
This is almost certainly the same issue as com.google.ads.AdView failed to instantiate. Particularly check out Eric's comment on screen sizes.
请确保您也声明AdActivity在AndroidManifest
Make sure you also declare the AdActivity in your AndroidManifest
<activity android:name="com.google.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
这篇关于com.google.ads.AdView未能实例化布局问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!