1

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)

Can somebody help my solve this problem? PLZ

bakusek
  • 135
  • 3
  • 17

3 Answers3

1

This is almost certainly the same issue as com.google.ads.AdView failed to instantiate. Particularly check out Eric's comment on screen sizes.

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"/>
Community
  • 1
  • 1
William
  • 20,150
  • 8
  • 49
  • 91
  • Hi, now when I made changes in my manifest and when I start my app in place when ad should be appear i see this information in red colour: "Missing AdActivity with android:configChange AndroidManifest.xml" plz help my i'm thinking that i am one step from success – bakusek Nov 21 '13 at 18:40
  • You also need to add the AdActivity into your AndroidManifest. See my altered answer. – William Nov 22 '13 at 03:53
0

Try this i am sure this will work, shift the adview inside the scope of either the linear/relative layout, in your case relative layout. And make sure you have edited your manifest file accordingly. I gaurantee this will work.

Hasan
  • 36
  • 1
  • 16
0
  1. Click the project name.
  2. Right Click to open module settings.
  3. Go to tab Dependencies.
  4. Click on Add button.
  5. Choose Library dependencies.
  6. Choose Play-Services.