Post Reply

Block ads on your Android phone (2010-04-15)

OP phaelox

15th April 2010, 10:52 PM   |  #1  
OP Senior Member
Thanks Meter: 12
 
107 posts
Join Date:Joined: Feb 2009
AdFree is a fantastic program created by XDA user delta_foxtrot2 (see this thread in the G1 forum) to facilitate using your hosts file to block ad servers. This makes it extremely easy. Of course you will need root access!


Unfortunately I found some ads still weren't blocked and the last update to the AdFree hosts file happened 2010-02-27. So I decided to update the hosts file myself. I merged the hosts files from adfree/mvps/yoyo and added a bunch of mobile ad providers I've found myself. The list is free of duplicates and comments, so as to keep it as small as possible (it still amounts to about 635 kB).

To install this hosts file, you still need root access obviously:
  1. download the zip
  2. unpack it to the directory where adb.exe is located (if you don't know what adb is or how to get it running, please use the search)
  3. open a command prompt
Code:
adb shell mount -o rw,remount -t yaffs2 /dev/block/mtdblock3 /system 
adb push hosts.for.mobile.txt /etc/hosts
adb shell mount -o ro,remount -t yaffs2 /dev/block/mtdblock3 /system
You might need to restart your phone. Also clearing the Android browser cache will apparently help in getting rid of already cached ads (worked for me, ymmv).


As for ethical discussions on blocking ads for free apps, blah. I don't so much have a problem with ads, as I do with the personal data that gets send to the ad providers. I'm talking about location data and whatever else they might want to know about my device and what I'm running ("analytics" is a fancy name for "we want to find out as much about you as we possibly can get away with").

Anyway.. use it, don't use it, up to you.

Last updated

15-4-2010 23:23 (20808 hosts blocked)


.
Attached Files
File Type: zip hosts-file-for-android_2010-04-15.zip - [Click for QR Code] (129.1 KB, 19856 views)
Last edited by phaelox; 15th April 2010 at 11:01 PM.
The Following 8 Users Say Thank You to phaelox For This Useful Post: [ View ]
15th April 2010, 11:41 PM   |  #2  
loblaw's Avatar
Member
Thanks Meter: 3
 
47 posts
Join Date:Joined: Apr 2010
Thanks a bunch!
16th April 2010, 02:04 PM   |  #3  
Senior Member
Flag Atlanta, GA
Thanks Meter: 49
 
715 posts
Join Date:Joined: Jul 2009
More
Thanks for the updated hosts. So should we even bother with the program, especially if it doesn't get updated hardly at all?
16th April 2010, 02:07 PM   |  #4  
OP Senior Member
Thanks Meter: 12
 
107 posts
Join Date:Joined: Feb 2009
Re: Block ads on your Android phone (2010-04-15)
You're welcome!

If you push my hosts file, you don't need the AdFree app, but I wanted to acknowledge his work and give people a simpler alternative to using adb.

Best choice right now is my hosts file as it's simply more comprehensive.

Sent from my HTC Hero using the XDA mobile application powered by Tapatalk
16th April 2010, 02:20 PM   |  #5  
Senior Member
Flag Atlanta, GA
Thanks Meter: 49
 
715 posts
Join Date:Joined: Jul 2009
More
Quote:
Originally Posted by phaelox

You're welcome!

If you push my hosts file, you don't need the AdFree app, but I wanted to acknowledge his work and give people a simpler alternative to using adb.

Best choice right now is my hosts file as it's simply more comprehensive.

Sent from my HTC Hero using the XDA mobile application powered by Tapatalk

Understood. Yeah, it was a great start/beginning to blocking ads, but no updates. Thanks again.
18th April 2010, 04:28 PM   |  #6  
Junior Member
Thanks Meter: 0
 
10 posts
Join Date:Joined: Apr 2010
Thanks! I've been looking for something like this for awhile. Real quick question: is getting "Data connectivity errors" in browser normal with this? It didn't start till I pushed this on my phone.
18th April 2010, 07:00 PM   |  #7  
OP Senior Member
Thanks Meter: 12
 
107 posts
Join Date:Joined: Feb 2009
Quote:
Originally Posted by tmayne

Real quick question: is getting "Data connectivity errors" in browser normal with this? It didn't start till I pushed this on my phone.


Short answer: Yes.

Long answer:
You may know this, but I'll explain anyway. The way this works is as follows. The loopback address for any network interface is 127.0.0.1 -- this is the address for the device, but only from the device itself, it loops back on itself. We don't want to waste bandwidth with ads, or have ad providers collect all sorts of data on us, so we don't want to connect to them. Any FQDN -Fully Qualified Domain Name- (for example: analytics.admob.com) needs to be converted into an IP address to be able to connect to it. Here's where the 'hosts' file comes in. It's a simple text file with a record on each line that says redirect 'hostname' to 'ip-address'. So we put a line in that reads '127.0.0.1 analytics.admob.com'. This tells our device that any connection made to 'analytics.admob.com' needs to be redirected to '127.0.0.1', which is your device. Basically a dead-end, as you are not running their webserver serving ads on your device, so this results in a data connection error.

Now, usually you will surf to a site that loads images (advertisements) from a server that is listed in this hosts file, and as a result the ads will not load. That shouldn't popup any error windows. But if you try to visit http://analytics.admob.com in your browser, then yes, you will see an error.

If the latter happens with a site you do wish to visit, just open the hosts file in a text editor (one that supports UNIX-style line ends) and remove the line in question, or put a '#' in front of the line to comment it out.

Hope that made it clearer.
Last edited by phaelox; 18th April 2010 at 07:03 PM.
The Following User Says Thank You to phaelox For This Useful Post: [ View ]
19th April 2010, 02:46 PM   |  #8  
Junior Member
Thanks Meter: 0
 
10 posts
Join Date:Joined: Apr 2010
Yeah it did. No worries though since it seems that after pressing "Ok" everything works fine! Small trade off for blocked ads! Thanks!
19th April 2010, 02:55 PM   |  #9  
carbonyle's Avatar
Member
Thanks Meter: 0
 
80 posts
Join Date:Joined: Aug 2007
More
Thumbs up
Thanks for this How-TO!

So basicaly that mean we can restrict acces to certain websites from our phone?
eg: adding this line
Code:
127.0.0.1 forum.xda-developers.com
and I'll no longer be able to browse XDA from my phone?

Keep writing such How-To, like this one and the one to sign update.zip, I found this interessant and usefull
19th April 2010, 03:18 PM   |  #10  
OP Senior Member
Thanks Meter: 12
 
107 posts
Join Date:Joined: Feb 2009
Quote:
Originally Posted by tmayne

Yeah it did. No worries though since it seems that after pressing "Ok" everything works fine! Small trade off for blocked ads! Thanks!

You're welcome, glad I could help.

Quote:
Originally Posted by carbonyle

Thanks for this How-TO!

So basicaly that mean we can restrict acces to certain websites from our phone?
eg: adding this line

Code:
127.0.0.1 forum.xda-developers.com
and I'll no longer be able to browse XDA from my phone?

Keep writing such How-To, like this one and the one to sign update.zip, I found this interessant and usefull

Cheers. And yes, that's exactly right. Just remember the hosts file takes FQDN's, so you can block a domain (or subdomain) this way, but not a directory or page on a domain. Also, blocking a domain does not also block its subdomains.

PS. this method of using the hosts file is not unique to your android phone, it works on most operating systems on PC as well. See this Wikipedia entry for more info.

Post Reply Subscribe to Thread

Tags
hosts block filter ads
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes