Com.google.ads.AdView failed to create instance

I used admob sdk and added as external jar.In xml I pointed

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
<TextView android:id="@+id/headerfield"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content">
<ListView android:id="@+id/list"
    android:layout_width="fill_parent"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content">

<com.google.ads.AdView 
    android:id="@+id/ad"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    ads:adSize="BANNER"    
    ads:adUnitId="Publisher Id"
    ads:loadAdOnCreate="true" />    
</LinearLayout>

manifest

<activity android:name="com.google.ads.AdActivity"
    android:configChanges="keyboard|keyboardHidden|orientation"/>

But in graphical mode, it gives me an error log:

com.google.ads.AdView - the following class could not be instantiated. 

Inside the program is displayed

You must have AdActivity declared in AndroidManifest.xml with configChanges.

+1
source share
3 answers

In the documentation you need to include additional settings in your activity (provided that you use 4.3.1 or later):

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

, screenSize smallestScreenSize , Android 3.2 . 4.1.1 ( 6.0.0 ).

+5

AdMob?

" " > " Java" > " "

, admob.jar; , .

+2

In case someone is still viewing this topic, check to see if the level of the API you are showing the view is lower. 17. For me, this worked in 17. You can change it using a small droid just above your graphic layout.

0
source

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


All Articles