yashsingh1/xdaforums huggingface dataset:
[Hero, G2 Touch General] wuud:
started adfree and it wanted to update, it tried to download new files but I got this error "Failed to remove /system/etc/hosts so it could be replaced." :/
[Hero, G2 Touch General] scholbert:
Well i personally don't use adfree from the market, but it uses the same procedures ...

So if you're using the method like it is described here, just read:

Are you rooted?

Regards,

scholbert
[Hero, G2 Touch General] pancrazio:
adfree "unable to get root access"

Hi, I am on Motorola Milestone 2.0 UK, installed Adfree but I get a message "I was unable to get root access...click ok to find out how to root your phone" and then it gets stuck on a black screen and I need to restart. But mine is rooted (I even managed to delete apps like YouTube...) and normally if an app needs root access it asks if I want to grant it root when it opens and this one doesn't.
[Hero, G2 Touch General] flipmode_11:
THE MAJOR PROBLEM WITH THIS FORUM IS THAT: NONE OF THE INFORMATION IS EVER ... 'RIGHT'...

Someone posts some very vague instructions, often wrong or forgets not everyone are hard-core developers, so nothing works!

What is wrong with people spending 5 minutes writing Step-by-step instructions are that are VERIFIED and TESTED after they type them?

QUESTION:

Can someone please provide word for word and step by step instructions???

QUESTION:

IS THERE AN UPDATE FOR THIS YET TO BLOCK NEW ADVERT SERVERS?
[Hero, G2 Touch General] Airbag888:
Lol really man? Is that a flame bait or something?

1. You're circumventing a way for regular devs to get money

2. Instructions (wrong or not legible enough for you) are graciously made/given by people you are not paying in anyway

3. Generalisation
[Hero, G2 Touch General] pulser_g2:
Please try and keep a less abusive tone towards other members.

Perhaps reading up on the XDA Mantra (the kind of reasons this site was founded) would help understand why people won't always write tried, tested beginnner guides going through every step.

To answer your question, no I can't provide step-by-step instructions for you, as that is a very subjective thing, and the way you have set up and installed ADB is different for everyone (in terms of install location etc). What I will do is explain everything non-user-specific in a clear way for you.

1) Download the latest ad-blocking hosts file (google it). hint: this is probably the best one http://www.mvps.org/winhelp2002/hosts.htm. It was updated at September-22-2010

2) Remount your device's file system (adb remount), then adb pull the current hosts file from /system/etc/hosts as a backup, and adb push this new hosts file downloaded from mvps.org to the same file (/system/etc/hosts).

3) chmod the permissions to be 644 (this may or may not be required, but doing it does no harm)

4) Reboot your device and check ads are blocked.

I have not tested these instructions, as I can't possibly go and test every single thing I post. If I did that, I would constantly be re-flashing my phone to remove things I was testing for other people.

But there's no need to test instructions like this. The basic theory I have learned of networking and linux/android tells me that it will work.

So... here you go, a command log for you to follow (you will need to ensure adb is set up correctly and the hosts file is in present working directory. That is an exercise for the reader)

adb remount
adb pull /system/etc/hosts hostsbackup
adb push hosts /system/etc/hosts
adb shell chmod 644 /system/etc/hosts
adb shell sync
adb shell reboot

These instructions are re-usable, and if you need an updated hosts file, look for one online, or manually add the domains to it.

This hosts file simply redirects ad servers to 127.0.0.1, which is the local loopback address, which won't resolve since your phone isn't running a web server (or at least it isn't likely to be doing so)

Please try to be more considerate to other members who give up their own time to provide information to users out of the goodness of their hearts, and treat this as a warning with regard to shouting and flame-baiting.

Regards

Pulser
[Hero, G2 Touch General] solid0snake:
Thank you for this helpful answer but is there a possability to enalbe the Adblocker when 3G is used.

For it seems quite useless if u have an adblocker on WLAN and not on 3G. My Dataplan is limited anyways so i hate to waste it on some useless ads.
[Hero, G2 Touch General] ionstorm3:
Block ads over 3G connection

The hosts file is queried when using the 3G connection. Just edit the hosts file and reboot your phone. Then use the 3G connection and you will see that it functions correctly. I have successfully blocked ads over 3G on the Motorola Droid, Motorola X and Samsung Captivate. Do not use the Adblocker app. Just edit the hosts file manually, it will save you a lot of trouble down the road (dont need to worry about the OS being up to date or the app not working).
[Hero, G2 Touch General] rs1990:
I tried this out, but don't think that it is working for me with the hosts file setup like ionstorm3 posted. I am still getting the AdMod ads in 2 apps that I tested (gReader and YourGolf).

Anything else that I could test/try? Thanks.
[Hero, G2 Touch General] rs1990:
Little more info, I have verified that I have a hosts file called /etc/hosts that is 605.76 K in size and I looked at the text and it looks good.
[Hero, G2 Touch General] pulser_g2:
Are you getting ads when surfing the web? If not, you just need admob servers to be added to your hosts list. If you Google for "admob hosts file block", then you will likely find a list of servers you can add to the existing list.
[Hero, G2 Touch General] stankcheeze:
Classy reply, helpful post. Thanks.
[Hero, G2 Touch General] Reflxxx:
Hi phaelox,

Works great but the adds in the apps from developer XIMAD are still there, can you please update the hosts file, thanks in advance..
[Hero, G2 Touch General] pulser_g2:
If you tell us the server names,we can help you remove them.

But if the adverts are not online, then you can't block them using hosts file.
[Hero, G2 Touch General] tsheeley:
How do you go about finding out the server names? I don't recall seeing any ads lately, but for future reference, it's good to know.
[Hero, G2 Touch General] pulser_g2:
That was an exercise for the reader ;) You could try and sniff packet URLs via your wifi router, or check logcat.

But going to this effort, why not buy the paid version, or ask the dev to offer one without ads.

Certainly, if i were to code an app with ads, it would be easy to prevent this blocker. Using a direct IP address connection to my server to retrieve adverts bypasses the hosts file, and storing a cached advert in the apk for a "buy full" banner would ensure one always appeared.

But to answer the question, you likely need to sniff the url via your router, or a specially configured wifi device listening to all traffic...
[Hero, G2 Touch General] giovannivl:
Hi, on my SGS I9000T, push directly to /System doesn't work, then:

Find host file:

su

find -iname etc

R/: /system/etc/hosts

adb pull /system/etc/host hostbckp

adb push hosts /system/etc/host --> error permission...

So:

adb push hosts /sdcard

adb shell

su

cp /sdcard/hosts /system/etc/hosts

Taraaaaa...

Updated file on http://www.mvps.org/winhelp2002/hosts.htm, thanks to that post that give us this link! because i don't remember the number...
[Hero, G2 Touch General] Reflxxx:
Yeah, but how do I get the "Server names"? Im sure the ads are ONLINE! Thanks for your reply.

EDIT: Sorry, just noticed the posts above!
[Hero, G2 Touch General] pulser_g2:
As I said, that's up to you. I don't know what equipment you have available, but a router that lets you view a log of requests would help etc.

Not easy, but it's the only way likely...
[Hero, G2 Touch General] cdchris12:
Samsung Vibrant Instructions

So, this didn't work on my Vibrant. Here's how I did it:

First, I changed the name of "hosts.for.mobile.txt" to "hosts", and placed it in /sdcard/. [adb push hosts /sdcard/hosts]

This is where I deviate from the instructions a bit. I couldn't get adb shell to do anything without su permissions, so I had to start an adb shell and elevate it to su. [adb shell] ---> [su] (if you get a prompt on the phone asking for root privileges, click accept.)

Next, I mounted the /system folder as rw. [mount -o rw,remount -t yaffs2 /dev/block/mtdblock3 /system]

Lastly, I simply moved the hosts file from /sdcard/hosts to /system/etc/hosts. [mv /sdcard/hosts /system/etc/hosts] (If you have problems with this step, you might try using root explorer to copy and paste the file from /sdcard/ to /system/etc/)

To finish, you should probably remount the /system folder as ro. [mount -o ro,remount -t yaffs2 /dev/block/mtdblock3 /system]

And viola, you have just completed changing your hosts file on your Samsung Vibrant.
[Hero, G2 Touch General] Ampicillin:
works great thanks
[Hero, G2 Touch General] Xeronix:
Been testing this out with my D1.

I'm now developing a small Apache application to echo a transparent to a wildcard request on 127.0.0.1, hence getting rid of the stupid "Web page not found" pages.
[Hero, G2 Touch General] cdchris12:
I'd rather see those page not found pages than see my battery icon blinking red at me after a couple hours of playing the "free" version of some game...
[Hero, G2 Touch General] Xeronix:
That's my concern aswell, however I'm pretty sure I can actually develop a process that runs in the actual rom itself..
[Hero, G2 Touch General] cb474:
What is the benefit of downloading this file manually and installing manually, as explained in this thread, over using the AdFree app that uses the same hosts file (from MVPS) and updates it automatically?

I thought the benefit of phaelox's original post, which began this thread, was that he was providing a hosts file that combined several different host files from different people. But it looks like phaelox has not updated that host file since April.

So doesn't downloading the MVPS hosts file directly and installing it manually just do the same thing that AdFree does automatically? If there's a better hosts file than AdFree provides, I'm interested. Otherwise, I'm not sure I understand the value of this method.
[Hero, G2 Touch General] scholbert:
This simply is the DIY method.

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

Regards,

scholbert
[Hero, G2 Touch General] cb474:
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.
[Hero, G2 Touch General] nico1375:
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
[Hero, G2 Touch General] NetDevil2:
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
[Hero, G2 Touch General] Val3r10:
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
[Hero, G2 Touch General] krosenqu:
Bump.

How do I monitor the traffic going though Android?
[Hero, G2 Touch General] tsheeley:
Read back a bit of posts... I asked the same thing, it's not an easy process.
[Hero, G2 Touch General] GodsDead:
Is this still the best method for blocking ads? if so are their any upto date host lists?
[Hero, G2 Touch General] khaytsus:
Hasn't changed. Either you push the hosts file yourself or install adfree as mentioned in the first post or so, it is on the market..

http://www.appbrain.com/app/adfree-android/com.bigtincan.android.adfree

You still have to have root.
[Hero, G2 Touch General] serjs:
It's for root only?
[Hero, G2 Touch General] OrganizedFellow:
Yes, root only.

SuperUser permissions is needed to access/modify /etc/hosts file.
[Hero, G2 Touch General] raouldj:
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.
[Hero, G2 Touch General] raouldj:
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.
[Hero, G2 Touch General] sjaak1234:
If I try using the commands from the post or the readme it doesn't work.

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?
[Hero, G2 Touch General] petemt:
Amazing, thanks, great :p, don't have much more to say :).

Lifechanger :p
[Hero, G2 Touch General] mexifelio:
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 :)
[Hero, G2 Touch General] carpao:
deleted......
[Hero, G2 Touch General] bogo_mips:
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!
[Hero, G2 Touch General] Treatcon:
Works very well, thank you. Next time you update can you block the ads in Flikie Wallpapers please.
[Hero, G2 Touch General] tadpolegthomas:
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?
[Hero, G2 Touch General] bogo_mips:
Hey Treatcon - glad you've managed to get it working :)

I'm not intending to keep merging hosts files as a service - that is why I made the hosts file merger application - so anyone can make their own hosts file from their favorite sources, or add their own domains into the mix.

It is quite possible that you may still have an app or two that get their adds from a domain which is not listed in the hosts file I posted on http://mathdotrandom.blogspot.com/2010/12/block-ads-on-pc-android-with-uber-hosts.html

However - it is possible that the app in question (Flikie Wallpapers) might have started up before you swapped to the new hosts file... I would recommend killing that app (via a task manager), and starting it up again, and see if the ads are still present.

If not, you might be able to track down which domain the ads are coming from by running a netstat app in the background (search for "Android Status" in the market), and see if you can track down that ad server! (it does require a bit of luck with the timing...)

Please post back here with the details if you do! :)

Thanks
[Hero, G2 Touch General] :No-Frost::
How can I install this using terminal emulator, as I tried to use ADB but I can't use it with my Desire HD...
[Hero, G2 Touch General] remizik:
Hi,

I replaced my hosts file with this one, but I'm still having ads everywhere :(

Angrybirds for example

am I the only one ? maybe I did something wrong.

Thanks

----> SOLUTION :

forget what I said, the file on my "/system/etc/" was named "HOSTS" instead of "hosts".

Caps are important.

It's ok now.
[Hero, G2 Touch General] :No-Frost::
its not working on my Desire HD... I have it in System/ETC and in ETC/hosts and nothing, I still can see all the adds =(...
[Hero, G2 Touch General] bogo_mips:
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

S

ystem 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...
[Hero, G2 Touch General] :No-Frost::
Testing RIGHT AWAY!!!!!
[Hero, G2 Touch General] :No-Frost::
Thanks mate, it worked amazingly good... Will keep that on my tips =D...
[Hero, G2 Touch General] Treatcon:
Roger that will report back with progress, thanks. :)
[Hero, G2 Touch General] Jaszy:
Not work on HTC Desire since last update. (Leedroid 2.3c)

Error:

Failed to remove /system/etc hosts so it could be replaced.
[Hero, G2 Touch General] bigtunes:
Getting this as well on my Desire. (2.29.405.2 by DaCe - rooted stock ROM)
[Hero, G2 Touch General] DatterBoy:
Hello!

Had been using this on my Rooted Nook Color and seems it is no longer working. been getting a number of different errors, some of which come and go but generlaly don't persist, but regardless, ads keep showing up in apps that don't show ads on my DINC counyterpart.

Angry Birds

Wordfeud

The errors I get are:

java.io.EOFException

Failed to remove /system/etc hosts so it could be replaced

And one more I can't seem to recreate. I've had the error happen on 2 Nook Colors, one fresh out of box and rooted clean.

Thoughts?

:Dat
[Hero, G2 Touch General] Bingley:
I'm having similar problems: ads in Angry Birds etc; the AF app says it's installed, updated and working properly, but the file appears as 0.00B - empty. Any ideas?
[Hero, G2 Touch General] ScHiZii:
Works great thanks alot!

I am using this on my iPhone 4, perfect :p
[Hero, G2 Touch General] Bingley:
Update works, apart from Appbrain; thanks.
[Hero, G2 Touch General] cobo_:
Looks like something is trying to delete your hosts file and create a new one/restore to default.

Maybe some app developers have cottoned-on to this and are trying to remove hosts file on install of their app, or Android updates are trying to do it?

Either way, ads in apps are bad, as phaelox has pointed out.

----

Where's our privacy gone?
[Hero, G2 Touch General] sjaak1234:
Impossible to get this to work on my Legend. adb just doesn't work. Get different errors depending on what commands I use.

Also root explorer way doesn't work because it keeps *****ing about not having enough free space. Obviously that is total bull****.

Adfree just keeps rebooting my phone.

Any tips?
[Hero, G2 Touch General] sjaak1234:
Seriously, this just seems impossible.

There is no way adb or any other app allows me push or copy the damn hosts file. wget doesnt work. cp says not found. So I googled it. Need to install more stuff (why the **** isn't there a cp option by default?), install busybox, use the busybox adb, still same error.

Why why why???
[Hero, G2 Touch General] mayurh:
hi there

is there an updated hosts file the one in the op says 2010?
[Hero, G2 Touch General] sjaak1234:
**** me, I had it. Flashed a different rom to see if maybe this would allow me to edit the system folder but no. Should have known it though. How the **** anybody can write such a piece of disfunctional software is beyond me. Basically I get to rw mounting the system but that's it. Push commands? Not found. cp command? not found. Wget? not found. Same **** in Terminal ap. Or I get directory not empty errors which I can't solve either (posts in this topic don't help).

How much effort can it take to edit a ****ing hosts file? Have All OS I ever worked with this is about a 5 second job.
[Hero, G2 Touch General] sjaak1234:
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.