title: The following classes could not be instantiated: - com.google.ads.AdView Admob
body: <p>I'm new to Admob sdk and I'm adding Admob on an app I'm developing but I'm getting error on the xml.</p>
  
  <p>This is my xml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;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" &gt;
  
  &lt;com.google.ads.AdView
      android:id="@+id/ad"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      ads:adUnitId="SAMPLE"
      ads:loadAdOnCreate="true" /&gt;
  
  &lt;LinearLayout
      android:id="@+id/mainLayout"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:gravity="center"
      android:orientation="horizontal" &gt;
  &lt;/LinearLayout&gt;
  
  &lt;RelativeLayout
      android:layout_width="fill_parent"
      android:layout_height="45dp"
      android:background="#081f34" &gt;
  
      &lt;LinearLayout
          android:layout_width="wrap_content"
          android:layout_height="45dp"
          android:gravity="center"
          android:orientation="horizontal" &gt;
  
          &lt;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" /&gt;
      &lt;/LinearLayout&gt;
  
      &lt;LinearLayout
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_alignParentRight="true"
          android:layout_centerVertical="true" &gt;
  
          &lt;View
              android:layout_width="0.5dp"
              android:layout_height="match_parent"
              android:layout_gravity="center"
              android:background="#8998a5" /&gt;
  
          &lt;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" /&gt;
  
          &lt;View
              android:layout_width="0.5dp"
              android:layout_height="match_parent"
              android:layout_gravity="center"
              android:background="#8998a5" /&gt;
  
          &lt;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" /&gt;
  
          &lt;ProgressBar
              android:id="@+id/refreshBar"
              android:layout_width="45dp"
              android:layout_height="45dp"
              android:padding="10dp"
              android:visibility="gone" /&gt;
  
          &lt;View
              android:layout_width="0.5dp"
              android:layout_height="match_parent"
              android:layout_gravity="center"
              android:background="#8998a5" /&gt;
  
          &lt;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" /&gt;
      &lt;/LinearLayout&gt;
  &lt;/RelativeLayout&gt;
  
  &lt;LinearLayout
      android:layout_width="fill_parent"
      android:layout_height="1dp"
      android:background="#8998a5" &gt;
  &lt;/LinearLayout&gt;
  
  &lt;LinearLayout
      android:layout_width="match_parent"
      android:layout_height="0dp"
      android:layout_margin="10dp"
      android:layout_weight="1"
      android:orientation="vertical" &gt;
  
      &lt;RelativeLayout
          android:id="@+id/content"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:background="#c9d2da" &gt;
  
          &lt;LinearLayout
              android:id="@+id/wrap1"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:orientation="horizontal"
              android:padding="5dp" &gt;
  
              &lt;TextView
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:text="Today is "
                  android:textSize="14dp" /&gt;
  
              &lt;TextView
                  android:id="@+id/t1"
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:text=""
                  android:textSize="14dp" /&gt;
          &lt;/LinearLayout&gt;
  
          &lt;View
              android:id="@+id/v1"
              android:layout_width="match_parent"
              android:layout_height="1dp"
              android:layout_below="@+id/wrap1"
              android:background="#0b2f50" /&gt;
  
          &lt;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" &gt;
  
              &lt;LinearLayout
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"
                  android:orientation="horizontal" &gt;
  
                  &lt;TextView
                      android:layout_width="130dp"
                      android:layout_height="wrap_content"
                      android:gravity="right"
                      android:text="Destination: "
                      android:textSize="20dp" /&gt;
  
                  &lt;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" /&gt;
              &lt;/LinearLayout&gt;
  
              &lt;LinearLayout
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"
                  android:orientation="horizontal"
                  android:paddingTop="5dp" &gt;
  
                  &lt;TextView
                      android:layout_width="130dp"
                      android:layout_height="wrap_content"
                      android:gravity="right"
                      android:text="Distance: "
                      android:textSize="20dp" /&gt;
  
                  &lt;LinearLayout
                      android:layout_width="0dp"
                      android:layout_height="wrap_content"
                      android:layout_gravity="center"
                      android:layout_weight="1"
                      android:orientation="vertical" &gt;
  
                      &lt;TextView
                          android:id="@+id/t3a"
                          android:layout_width="wrap_content"
                          android:layout_height="wrap_content"
                          android:text=""
                          android:textSize="20dp"
                          android:textStyle="bold" /&gt;
  
                      &lt;TextView
                          android:id="@+id/t3b"
                          android:layout_width="wrap_content"
                          android:layout_height="wrap_content"
                          android:text=""
                          android:textSize="16dp" /&gt;
                  &lt;/LinearLayout&gt;
              &lt;/LinearLayout&gt;
          &lt;/LinearLayout&gt;
  
          &lt;View
              android:id="@+id/v2"
              android:layout_width="match_parent"
              android:layout_height="1dp"
              android:layout_below="@+id/wrap2"
              android:background="#0b2f50" /&gt;
  
          &lt;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" /&gt;
  
          &lt;LinearLayout
              android:id="@+id/wrap3"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:layout_below="@+id/title1"
              android:orientation="vertical" &gt;
  
              &lt;LinearLayout
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"
                  android:orientation="horizontal"
                  android:paddingLeft="5dp"
                  android:paddingRight="5dp" &gt;
  
                  &lt;LinearLayout
                      android:layout_width="140dp"
                      android:layout_height="wrap_content" &gt;
  
                      &lt;TextView
                          android:layout_width="60dp"
                          android:layout_height="wrap_content"
                          android:gravity="right"
                          android:text="Mode: "
                          android:textSize="15dp"
                          android:textStyle="bold" /&gt;
  
                      &lt;TextView
                          android:id="@+id/t4"
                          android:layout_width="wrap_content"
                          android:layout_height="wrap_content"
                          android:text="In-Range"
                          android:textSize="15dp" /&gt;
                  &lt;/LinearLayout&gt;
  
                  &lt;LinearLayout
                      android:layout_width="0dp"
                      android:layout_height="wrap_content"
                      android:layout_weight="1" &gt;
  
                      &lt;TextView
                          android:layout_width="60dp"
                          android:layout_height="wrap_content"
                          android:gravity="right"
                          android:text="Sound: "
                          android:textSize="15dp"
                          android:textStyle="bold" /&gt;
  
                      &lt;TextView
                          android:id="@+id/t5"
                          android:layout_width="wrap_content"
                          android:layout_height="wrap_content"
                          android:singleLine="true"
                          android:text=""
                          android:textSize="14dp" /&gt;
                  &lt;/LinearLayout&gt;
              &lt;/LinearLayout&gt;
  
              &lt;LinearLayout
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"
                  android:orientation="horizontal"
                  android:paddingLeft="5dp"
                  android:paddingRight="5dp" &gt;
  
                  &lt;LinearLayout
                      android:layout_width="140dp"
                      android:layout_height="wrap_content" &gt;
  
                      &lt;TextView
                          android:layout_width="60dp"
                          android:layout_height="wrap_content"
                          android:gravity="right"
                          android:text="Range: "
                          android:textSize="15dp"
                          android:textStyle="bold" /&gt;
  
                      &lt;TextView
                          android:id="@+id/t6"
                          android:layout_width="wrap_content"
                          android:layout_height="wrap_content"
                          android:text=""
                          android:textSize="15dp" /&gt;
                  &lt;/LinearLayout&gt;
  
                  &lt;LinearLayout
                      android:layout_width="0dp"
                      android:layout_height="wrap_content"
                      android:layout_weight="1" &gt;
  
                      &lt;TextView
                          android:layout_width="60dp"
                          android:layout_height="wrap_content"
                          android:gravity="right"
                          android:text="Vibrate: "
                          android:textSize="15dp"
                          android:textStyle="bold" /&gt;
  
                      &lt;TextView
                          android:id="@+id/t7"
                          android:layout_width="wrap_content"
                          android:layout_height="wrap_content"
                          android:text=""
                          android:textSize="15dp" /&gt;
                  &lt;/LinearLayout&gt;
              &lt;/LinearLayout&gt;
          &lt;/LinearLayout&gt;
  
          &lt;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" /&gt;
  
          &lt;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" /&gt;
  
          &lt;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" /&gt;
      &lt;/RelativeLayout&gt;
  &lt;/LinearLayout&gt;
  
  &lt;LinearLayout
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      android:gravity="center_vertical"
      android:orientation="vertical" &gt;
  
      &lt;View
          android:layout_width="match_parent"
          android:layout_height="1dp"
          android:background="#0a1d2e" /&gt;
  
      &lt;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" /&gt;
  &lt;/LinearLayout&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>I add the adView on the top but I'm getting error.</p>
  
  <p>Here is the error:</p>
  
  <pre><code>The following classes could not be instantiated:
  - com.google.ads.AdView (Open Class, Show Error Log)
  See the Error Log (Window &gt; 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.&lt;init&gt;(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)
  </code></pre>
  
  <p>Can someone help me to fix this. Thank you.</p>