Les classes suivantes ne peut pas être instancié: - com.google.les annonces.AdView Admob

Je suis nouveau sdk Admob et je suis en ajoutant Admob sur une application que je suis en développement, mais j'obtiens une erreur sur le xml.

C'est mon xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#0b2f50"
android:orientation="vertical" >
<com.google.ads.AdView
android:id="@+id/ad"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adUnitId="SAMPLE"
ads:loadAdOnCreate="true" />
<LinearLayout
android:id="@+id/mainLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal" >
</LinearLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="45dp"
android:background="#081f34" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="45dp"
android:gravity="center"
android:orientation="horizontal" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="5dp"
android:inputType="textNoSuggestions"
android:src="@drawable/logo2" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true" >
<View
android:layout_width="0.5dp"
android:layout_height="match_parent"
android:layout_gravity="center"
android:background="#8998a5" />
<ImageView
android:id="@+id/ImgVdetails"
android:layout_width="45dp"
android:layout_height="45dp"
android:background="@layout/btn_save"
android:padding="10dp"
android:src="@drawable/info" />
<View
android:layout_width="0.5dp"
android:layout_height="match_parent"
android:layout_gravity="center"
android:background="#8998a5" />
<ImageView
android:id="@+id/refresh"
android:layout_width="45dp"
android:layout_height="45dp"
android:background="@layout/btn_save"
android:padding="10dp"
android:src="@drawable/refresh" />
<ProgressBar
android:id="@+id/refreshBar"
android:layout_width="45dp"
android:layout_height="45dp"
android:padding="10dp"
android:visibility="gone" />
<View
android:layout_width="0.5dp"
android:layout_height="match_parent"
android:layout_gravity="center"
android:background="#8998a5" />
<ImageView
android:id="@+id/imageButton1"
android:layout_width="55dp"
android:layout_height="45dp"
android:background="@layout/btn_save"
android:contentDescription="@string/btnSettings"
android:padding="10dp"
android:src="@drawable/settings" />
</LinearLayout>
</RelativeLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="1dp"
android:background="#8998a5" >
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_margin="10dp"
android:layout_weight="1"
android:orientation="vertical" >
<RelativeLayout
android:id="@+id/content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#c9d2da" >
<LinearLayout
android:id="@+id/wrap1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="5dp" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Today is "
android:textSize="14dp" />
<TextView
android:id="@+id/t1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:textSize="14dp" />
</LinearLayout>
<View
android:id="@+id/v1"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_below="@+id/wrap1"
android:background="#0b2f50" />
<LinearLayout
android:id="@+id/wrap2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/v1"
android:orientation="vertical"
android:paddingBottom="5dp"
android:paddingTop="5dp" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:layout_width="130dp"
android:layout_height="wrap_content"
android:gravity="right"
android:text="Destination: "
android:textSize="20dp" />
<TextView
android:id="@+id/t2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:text=""
android:textSize="20dp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingTop="5dp" >
<TextView
android:layout_width="130dp"
android:layout_height="wrap_content"
android:gravity="right"
android:text="Distance: "
android:textSize="20dp" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:orientation="vertical" >
<TextView
android:id="@+id/t3a"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:textSize="20dp"
android:textStyle="bold" />
<TextView
android:id="@+id/t3b"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:textSize="16dp" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
<View
android:id="@+id/v2"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_below="@+id/wrap2"
android:background="#0b2f50" />
<TextView
android:id="@+id/title1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/v2"
android:padding="5dp"
android:text="ALARM SETTINGS"
android:textSize="14dp" />
<LinearLayout
android:id="@+id/wrap3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/title1"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingLeft="5dp"
android:paddingRight="5dp" >
<LinearLayout
android:layout_width="140dp"
android:layout_height="wrap_content" >
<TextView
android:layout_width="60dp"
android:layout_height="wrap_content"
android:gravity="right"
android:text="Mode: "
android:textSize="15dp"
android:textStyle="bold" />
<TextView
android:id="@+id/t4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="In-Range"
android:textSize="15dp" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1" >
<TextView
android:layout_width="60dp"
android:layout_height="wrap_content"
android:gravity="right"
android:text="Sound: "
android:textSize="15dp"
android:textStyle="bold" />
<TextView
android:id="@+id/t5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true"
android:text=""
android:textSize="14dp" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingLeft="5dp"
android:paddingRight="5dp" >
<LinearLayout
android:layout_width="140dp"
android:layout_height="wrap_content" >
<TextView
android:layout_width="60dp"
android:layout_height="wrap_content"
android:gravity="right"
android:text="Range: "
android:textSize="15dp"
android:textStyle="bold" />
<TextView
android:id="@+id/t6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:textSize="15dp" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1" >
<TextView
android:layout_width="60dp"
android:layout_height="wrap_content"
android:gravity="right"
android:text="Vibrate: "
android:textSize="15dp"
android:textStyle="bold" />
<TextView
android:id="@+id/t7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:textSize="15dp" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
<View
android:id="@+id/v3"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_below="@+id/wrap3"
android:layout_marginBottom="5dp"
android:layout_marginTop="5dp"
android:background="#0b2f50" />
<TextView
android:id="@+id/title2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/v3"
android:paddingLeft="5dp"
android:text="STATUS"
android:textSize="14dp" />
<TextView
android:id="@+id/t8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/title2"
android:paddingLeft="15dp"
android:text=""
android:textSize="15dp" />
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="vertical" >
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#0a1d2e" />
<ToggleButton
android:id="@+id/TglBtn_setAlarm"
android:layout_width="fill_parent"
android:layout_height="55dp"
android:layout_weight="1.0"
android:background="@layout/btn_style"
android:textColor="#fff"
android:textOff="@string/TglBtn_setAlarmOn"
android:textOn="@string/TglBtn_setAlarmOff"
android:textSize="18sp"
android:textStyle="bold" />
</LinearLayout>
</LinearLayout>

- Je ajouter le adView sur le dessus, mais j'obtiens une erreur.

Voici l'erreur:

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:273)
at com.google.ads.AdView.a(SourceFile:394)
at com.google.ads.AdView.<init>(SourceFile:125)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(NativeConstructorAccessorImpl.java:-2)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
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:755)
at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:64)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:727)
at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
at android.view.LayoutInflater.inflate(LayoutInflater.java:373)

Quelqu'un peut-il m'aider à résoudre ce problème. Merci.

je voudrais faire le parent de l'adview un RelativeLayout au lieu d'un LinearLayout, je n'ai jamais pu obtenir une adview de travailler dans un LinearLayout
encore l'obtention de l'erreur, monsieur.
avez-vous le faire comme ma réponse?

OriginalL'auteur user2951348 | 2014-02-11