Com.google.ads.AdView failed to instantiate layout problem

I have a problem integrating adob ad with my layout. In the layout, I have a map fragment, linear and relative. I would like my ad to be on top or bottom of my application. 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 select the graphic layout, I have 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)

Can someone help me solve this problem? Plz

+1
source share
3 answers

This is almost certainly the same problem as com.google.ads.AdView failed to create an instance . In particular, check that Eric comments on the screen sizes.

, AdActivity AndroidManifest

<activity android:name="com.google.ads.AdActivity"
          android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
+1

, , , / , . , . , .

0
  • .
  • , .
  • "".
  • "".
  • .
  • Play-Services.
0

Source: https://habr.com/ru/post/1526279/


All Articles