Detecting Android devices that are blocking ads

A friend of mine pointed me in the direction of an interesting app a few days ago. They had been using it for a while and just installed an ad-blocker, the type that just modifies your host file with a bunch of known ad providers. Then they’re new favorite application stopped working, complaining that the ads where blocked. This may not have been the first attempt to detect ad removal, but it was the first one that I’ve looked at or even heard of. It’s nothing fancy of course, but it’s actually a nifty idea. The way it has been implemented there are plenty of ways to get around it, but it’s definitely was a nifty piece of code. Quiet trivial to patch if someone wanted to, though I see no reason to not support the devs.

Anyway, I quickly just reversed the code, since most people don’t care for reading the output of dexdump;

Maybe some other dev’s will find this useful.

UPDATE: It would appear the code I reversed was posted on StackOverFlow. No sense in deleting this page though – next time I’ll just have to Google a little better! 🙂

  1. Pretty cool. Kinda annoying for me since I have ads blocked in order to make web browsing faster, but if I could control the hosts file in a per-app basis, I’d definitely disable it for free apps that have ads.

  2. @Ankush

    If you remove entries containing “admob” this should allow free ad driven apps to function still

  3. admob.com would be a better solution.

    (i.e. my company’s name is MadMobileSolutions.com)

  4. But what will you do when the file /etc/hosts getting the 600 permission ? There is no longer a way to read this file except request to become root. And anyway, there is also iptables which can be used alternative.

  5. Hello

    I’ve created an open source android library that uses this method and others to detect ad blockers:



Your Name Email Website