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

Search This thread

cb474

Senior Member
Oct 25, 2010
1,051
392
This simply is the DIY method.

...some folks like to know what happens under the hood and discuss it :rolleyes:

Regards,

scholbert

Yes I like to know how things work under the hood too. But it did seem orignally this thread was providing a more complete hosts files than AdFree. I guess that's not the case anymore. Thanks for the explanation.
 

nico1375

Senior Member
Mar 16, 2008
292
15
Hello,

this makes me crazy. I tried to remount the filesystem rw, no output error so I guess it's ok.
But each time I try to copy the hosts file within the /etc, it gives me a "out of memory" error.

Anyone got a clue?


Thanks,
nico
 

NetDevil2

Member
Jun 18, 2008
20
1
Hello,

this makes me crazy. I tried to remount the filesystem rw, no output error so I guess it's ok.
But each time I try to copy the hosts file within the /etc, it gives me a "out of memory" error.

Anyone got a clue?


Thanks,
nico

Hi, I'm facing the 'Paste Failure: There was not enough free disk space to complete the paste operation. Please note that the free space displayed by Root Explorer (as reported by linux) is not always 100% accurate!' problem, i tried to delete the hosts file inside the system/etc but each time after i deleted and tried to paste the new hosts file, it said the hosts file already exist (the hosts file will auto generated no matter how many times i tried to delete), how weird... :|

any solution? thanks
 
Last edited:

Val3r10

Senior Member
Jul 6, 2006
228
6
Hello. Isn't there any update for this huge /etc/hosts file ?
I realized many ads are escaping the localhost jail.
How could I track, catch & report them ?
Any netstat logger ?

Thank you very much
 

raouldj

New member
Nov 27, 2010
2
0
Need help with basic issues

Hi guys,

Have a i5800 with stock firmware, nothing flashed changed.

I changed my phone to usb developnemt mode.

I ran z4root with temporary root option(since the unrooting is not supported yet). It says that i am rooted til next reboot & Superuser app appears(whatever that means).

I installed the development kit with all the tools including adb & added them to the path(Windows xp).

I am able to run adb & i am able to start adb shell & browse phones directories but that is unfortunately it.

[adb shell mount -o rw,remount -t yaffs2 /dev/block/mtdblock3 /system] gives me: mount: Operation not permitted

Starting adb shell & typing [su] returns: su: not found

So now what? What am i missing? How do i know if i´m properly rooted?

I suspect i´m not the only one who is struggling with those basic issues. Hope someone can help me on this one.
 

raouldj

New member
Nov 27, 2010
2
0
Hi guys,

Have a i5800 with stock firmware, nothing flashed changed.

I changed my phone to usb developnemt mode.

I ran z4root with temporary root option(since the unrooting is not supported yet). It says that i am rooted til next reboot & Superuser app appears(whatever that means).

I installed the development kit with all the tools including adb & added them to the path(Windows xp).

I am able to run adb & i am able to start adb shell & browse phones directories but that is unfortunately it.

[adb shell mount -o rw,remount -t yaffs2 /dev/block/mtdblock3 /system] gives me: mount: Operation not permitted

Starting adb shell & typing [su] returns: su: not found

So now what? What am i missing? How do i know if i´m properly rooted?

I suspect i´m not the only one who is struggling with those basic issues. Hope someone can help me on this one.
Since i finally got it working then i might as well describe here how i went about:
*Downloaded OneClickRoot(z4root does not work with samsung i5800 with stock version of android 2.1 eclair) from http://xdaforums.com/showthread.php?t=778880
*Unpacked the OneClickRoot package & moved root.zip file to the root directory of my sdcard. use usb mass storage mode if you like.
*Renamed root.zip to update.zip
*Installed Android Development Kit & used it to download & install USB drivers.
*Downloaded Microsoft .NET -because the guide told me to
*Connected phone in USB Development mode
*Ran rootme.bat
*Phone rebooted and i chose: apply sdcard:update.zip with volume button & pushed home button. I got Android logo with warning sign. PUSHED HOME BUTTON AGAIN. Root process ran & phone rebooted once more. -I was finally properly rooted.
*Went to android market & got Busybox + Terminal emulator.
*Ran Busybox installer app from phone
**Downloaded new file containing hosts. Renamed to hosts(without any extension) & copied to sdcard. Depending on your method you might need to turn off USB Development mode for that.
*Ran Terminal emulator -on the phone.
*su, enter
*Super user app informed me that terminal wants to get root privileges -grant them.
*$ changed to # indicationg that su mode was on
*cp /sdcard/hosts /system/etc/hosts or cp /sdcard/hosts /system/etc/ depending on the busybox version blah blah.

Hope this works for you as well. ps. i am running win xp.
 

sjaak1234

Senior Member
Jun 19, 2008
192
8
If I try using the commands from the post or the readme it doesn't work.

Code:
C:\AndroidSDK\tools>adb push hosts.for.mobile.txt /etc/hosts
failed to copy 'hosts.for.mobile.txt' to '/etc/hosts': Directory not empty

C:\AndroidSDK\tools>adb push hosts.for.mobile.txt /etc/hosts
failed to copy 'hosts.for.mobile.txt' to '/etc/hosts': Directory not empty

C:\AndroidSDK\tools>adb remount

C:\AndroidSDK\tools>adb push hosts.for.mobile.txt /etc/hosts
failed to copy 'hosts.for.mobile.txt' to '/etc/hosts': Read-only file system

C:\AndroidSDK\tools>adb shell mount -o rw,remount -t yaffs2 /dev/block/mtdblock3
 /system

C:\AndroidSDK\tools>adb push hosts.for.mobile.txt /etc/hosts
failed to copy 'hosts.for.mobile.txt' to '/etc/hosts': Directory not empty

C:\AndroidSDK\tools>

What am I doing wrong?

Also, I would like to try the app, but where can I find it? even in the link to the original creator its only a .txt file. No .apk anywhere?
 

mexifelio

New member
Sep 7, 2010
1
0
Awesome app

Is there a way to add or whitelist a site through the app?
If not, is there a way to remove the site from the hosts file through terminal?

Thanks :)
 

bogo_mips

Member
Feb 5, 2010
15
3
Uber hosts file

Hey

If you are not getting any luck with AdFree, I made a hosts file merger that you can use to merge a number of hosts files, with info on where to get the various hosts files, and instructions on how to apply it (manual method - requires rooted phone).

There is also a link to a fresh merged hosts file I did yesterday, which you can download and apply:

http://mathdotrandom.blogspot.com/2010/12/block-ads-on-pc-android-with-uber-hosts.html

You can use the hosts merger app to make your own, clean hosts file whenever you want!
 

Treatcon

Senior Member
Apr 6, 2010
794
173
Austin, TX
Samsung Galaxy S21 Ultra
Hey

If you are not getting any luck with AdFree, I made a hosts file merger that you can use to merge a number of hosts files, with info on where to get the various hosts files, and instructions on how to apply it (manual method - requires rooted phone).

There is also a link to a fresh merged hosts file I did yesterday, which you can download and apply:

http://mathdotrandom.blogspot.com/2010/12/block-ads-on-pc-android-with-uber-hosts.html

You can use the hosts merger app to make your own, clean hosts file whenever you want!

Works very well, thank you. Next time you update can you block the ads in Flikie Wallpapers please.

Sent from my Nexus One using XDA App
 

tadpolegthomas

New member
Jun 22, 2010
1
0
I noticed by adding adfree that now when tethering some sites are broken or don't function properly since this is the largest priority for my phone I was wondering if there was any way to reverse the process?
 

Top Liked Posts

  • There are no posts matching your filters.
  • 8
    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)


    .
    5
    Hello, since this is the top search result for this topic on Google I'd thought I'd share an update. This is a simple method:

    1. Boot into clockworkmod recovery
    2. partitions > mount /system
    3. adb push hosts /system/etc/hosts
    4. adb reboot

    No need to play with remount and permissions in recovery. Working on CM7 RC2 on HTC Aria. I have updated the hosts file using the sources in the comments as of March 8, 2011.

    Edit: Put mobile advertisers from original list back in and removed duplicates.
    2
    I've shamelessly stolen from the hosts files in this thread and then added my own to make an up-to-date list that mainly works for me.

    The file is sorted, (with the exception of the localhost entry), with duplicates removed.
    2
    caps are important - yes, however, it is strange that the hosts file is HOSTS on your Android ROM... but I guess nothing is impossible...

    @No-Frost: If you have Terminal Emulator and some Superuser app for granting root privileges, you can use the following:

    You need to place the hosts file on your SD card to begin with (in this example, the hosts file is: /mnt/sdcard/hosts.final)

    Next, you need to mount the filesystem in read-write mode, as it is read-only by default

    su
    mount -o remount,rw /dev/block/mtdblock3 /system
    mv /etc/hosts /etc/hosts.bak
    cp /mnt/sdcard/hosts.final /etc/hosts
    chmod 644 /etc/hosts
    mount -o remount,ro /dev/block/mtdblock3 /system
    ls -l /etc/hosts


    That should move the hosts.final file from the root of your SD card, into the /etc directory, and apply the filename: hosts

    Be weary of filenames and foldernames under linux - they are case-sensitive... you don't want System or ETC, etc.

    Once you've executed the last line in the script ls -l /etc/hosts, you should be able to verify that the hosts file exists, with the correct access rights.

    Maybe reboot at this point.

    Quit Terminal Emulator, open your browser, maybe clear the cache in the browser, and open one of the ad-servers listed in your hosts file, e.g.:
    http://00fun.com
    If the page fails to load, then everything worked!

    If you still get ads in apps or websites after the above test succeeded, then it could be that the specific app or website is sourcing it's ads from another host that is not yet in the hosts file, or via some other means...
    2
    Finally got it to work.

    Now there is no way I got this working from terminal app, adb + phone booted or default recovery mode (traingle screen). However if you boot into clockwork recovery mode, manually mount system and sdcard and than use the commands from this topic it will work.