title: How to use admob in android webview?
body: <p>Hi all I am using admob in android webview. When i integrated admob and run, it displays following error. My code is as follows:</p>
  
  <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:ads="http://schemas.android.com/apk/res-auto"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:orientation="vertical" &gt;
  
  &lt;com.google.ads.AdView
      android:id="@+id/adViews"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_alignParentBottom="true"
      android:layout_alignParentTop="false"
      android:layout_centerHorizontal="true"
      ads:adSize="BANNER"
      ads:adUnitId="ca-123456" &gt;
  &lt;/com.google.ads.AdView&gt;
  
  &lt;LinearLayout
      android:layout_alignParentTop="true"
      android:layout_above="@id/adView"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:orientation="vertical" &gt;
  
      &lt;ProgressBar
          android:id="@+id/progressBar1"
          style="?android:attr/progressBarStyleHorizontal"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
     /&gt;
  
      &lt;WebView
          android:id="@+id/webView1"
          android:layout_width="match_parent"
          android:layout_height="0dp"
          android:layout_weight="1" /&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p></p>
  
  <p>in code i used as:</p>
  
  <pre><code> private InterstitialAd interstitial;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      overridePendingTransition(R.anim.trans_left_in, R.anim.trans_left_out);
      setContentView(R.layout.activity_news);
  
  
       interstitial = new InterstitialAd(News.this);
          // Insert the Ad Unit ID
          interstitial.setAdUnitId("ca-app123456");
  
          //Locate the Banner Ad in activity_main.xml
          AdView adView = (AdView) this.findViewById(R.id.adViews);
  
          // Request for Ads
          AdRequest adRequest = new AdRequest.Builder()
  
          // Add a test device to show Test Ads..comment for real app when launching
           .addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
           .addTestDevice("CC5F2C72DF2B356BBF0DA198")
                  .build();
  
          // Load ads into Banner Ads
          adView.loadAd(adRequest);
  
          // Load ads into Interstitial Ads
          interstitial.loadAd(adRequest);
  
          // Prepare an Interstitial Ad Listener
          interstitial.setAdListener(new AdListener() {
              public void onAdLoaded() {
                  // Call displayInterstitial() function
                  displayInterstitial();
              }
          });
      }
      public void displayInterstitial() {
          // If Ads are loaded, show Interstitial else show nothing.
          if (interstitial.isLoaded()) {
              interstitial.show();
          }
  
      web=(WebView)findViewById(R.id.webView1);
  
      web.setWebViewClient(new WebViewClient());
      pb=(ProgressBar)findViewById(R.id.progressBar1);
      ActionBar ab=getActionBar();
      ColorDrawable cd=new ColorDrawable(Color.parseColor("#000000"));
      ab.setBackgroundDrawable(cd);
      ab.setDisplayHomeAsUpEnabled(true);
  
      WebSettings ws=web.getSettings();
      ws.setBuiltInZoomControls(true);
      web.setWebViewClient(new WebViewClient());
  
      web.setWebChromeClient(new WebChromeClient() {
        //showing webview
       }
       }
  </code></pre>
  
  <p>When i run the code it displays following error:</p>
  
  <pre><code>08-10 13:23:50.241: E/AndroidRuntime(13873): FATAL EXCEPTION: main
  08-10 13:23:50.241: E/AndroidRuntime(13873): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.all.news/com.all.news.News}: android.view.InflateException: Binary XML file line #7: Error inflating class com.google.ads.AdView
  08-10 13:23:50.241: E/AndroidRuntime(13873):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2306)
  08-10 13:23:50.241: E/AndroidRuntime(13873):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2358)
  08-10 13:23:50.241: E/AndroidRuntime(13873):    at android.app.ActivityThread.access$600(ActivityThread.java:156)
  08-10 13:23:50.241: E/AndroidRuntime(13873):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1340)
  08-10 13:23:50.241: E/AndroidRuntime(13873):    at android.os.Handler.dispatchMessage(Handler.java:99)
  08-10 13:23:50.241: E/AndroidRuntime(13873):    at android.os.Looper.loop(Looper.java:153)
  08-10 13:23:50.241: E/AndroidRuntime(13873):    at android.app.ActivityThread.main(ActivityThread.java:5297)
  08-10 13:23:50.241: E/AndroidRuntime(13873):    at java.lang.reflect.Method.invokeNative(Native Method)
  08-10 13:23:50.241: E/AndroidRuntime(13873):    at java.lang.reflect.Method.invoke(Method.java:511)
  08-10 13:23:50.241: E/AndroidRuntime(13873):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833)
  08-10 13:23:50.241: E/AndroidRuntime(13873):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
  08-10 13:23:50.241: E/AndroidRuntime(13873):    at dalvik.system.NativeStart.main(Native Method)
  08-10 13:23:50.241: E/AndroidRuntime(13873): Caused by: android.view.InflateException: Binary XML file line #7: Error inflating class com.google.ads.AdView
  08-10 13:23:50.241: E/AndroidRuntime(13873):    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:698)
  08-10 13:23:50.241: E/AndroidRuntime(13873):    at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
  08-10 13:23:50.241: E/AndroidRuntime(13873):    at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
  08-10 13:23:50.241: E/AndroidRuntime(13873):    at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
  08-10 13:23:50.241: E/AndroidRuntime(13873):    at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
  08-10 13:23:50.241: E/AndroidRuntime(13873):    at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:274)
  08-10 13:23:50.241: E/AndroidRuntime(13873):    at android.app.Activity.setContentView(Activity.java:1881)
  08-10 13:23:50.241: E/AndroidRuntime(13873):    at com.all.news.News.onCreate(News.java:35)
  08-10 13:23:50.241: E/AndroidRuntime(13873):    at android.app.Activity.performCreate(Activity.java:5122)
  08-10 13:23:50.241: E/AndroidRuntime(13873):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1081)
  08-10 13:23:50.241: E/AndroidRuntime(13873):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2270)
  08-10 13:23:50.241: E/AndroidRuntime(13873):    ... 11 more
  08-10 13:23:50.241: E/AndroidRuntime(13873): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.ads.AdView" on path: DexPathList[dexElements=[zip file "/data/app/com.all.news-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.all.news-1, /vendor/lib, /system/lib]]
  08-10 13:23:50.241: E/AndroidRuntime(13873):    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:53)
  08-10 13:23:50.241: E/AndroidRuntime(13873):    at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
  08-10 13:23:50.241: E/AndroidRuntime(13873):    at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
  08-10 13:23:50.241: E/AndroidRuntime(13873):    at android.view.LayoutInflater.createView(LayoutInflater.java:552)
  08-10 13:23:50.241: E/AndroidRuntime(13873):    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:687)
  08-10 13:23:50.241: E/AndroidRuntime(13873):    ... 21 more
  </code></pre>
  
  <p>Please help me to sort where I am doing mistake..</p>
  
  <p>Thanks in advance</p>