Android WebView – “ads failing to load” solution

I just spent a few hours debugging something, and I thought it might be worth posting in case anyone else out there might ever have this obscure problem.

My app brings up an external page in a WebView that contains ads.  My emulator and my phone (not rooted) brought up these pages with little problems, but on my rooted Transformer Tablet, in my assigned WebViewClient, I kept getting an onReceivedError method call, errorCode=-6, description=”The connection to the server was unsuccessful.”  This was happening on embedded doubleclick ad URLs and other external ad URLs.  I thought maybe there was some security setting that prevented cross-domain or cross-site loading of scripts or images, but that seemed to be a pretty extreme default setting for WebView.  (IE many sites load jquery directly from the jquery site, or use content delivery networks for images… both are valid cross-domain references.)

The quick of it is, the custom ROM I had installed (Revolution ROM) came with some anti-spyware measures which was blocking certain sites and firing errors off to my WebViewClient.  My stock /etc/hosts (/system/etc/hosts) file with this ROM looked something like this…

# Ad server list for use with hosts files to block ads
# For more information about this list, see:
# ----
# entries: 23609
# last updated
# AdFree Version 0.7.7 (7007)
# UID: 0
# sources:
# localhost

I was able to change it back to a simple: localhost

by following instructions here and the errors are gone.  Guess that’s what I get for using a non-stock rom, but having root sure is worth it.  🙂


Leave a Reply

Your email address will not be published. Required fields are marked *


This site uses Akismet to reduce spam. Learn how your comment data is processed.