How to prevent ad blocker from blocking ads on an app

One of my users let the cat out of the bag and told me they were using one of my free apps, which is monetized by ads, but they were blocking the ads with an ad blocker. They told me this mockingly, as if I can't do anything about it.

Can I do something about it? Is there a way to detect that ads are being blocked?


Solution 1:

I am aware of one way that ad blocking works (on any computer really), they edit the hosts file to point to localhost for all known ad servers. For android this is located in the "etc/hosts" file.

For example, I use admob ads and a host file that I have taken from custom rom lists the folowing admob entries:

127.0.0.1 analytics.admob.com
127.0.0.1 mmv.admob.com
127.0.0.1 mm.admob.com
127.0.0.1 admob.com
127.0.0.1 a.admob.com
127.0.0.1 jp.admob.com
127.0.0.1 c.admob.com
127.0.0.1 p.admob.com
127.0.0.1 mm1.vip.sc1.admob.com
127.0.0.1 media.admob.com
127.0.0.1 e.admob.com

Now anytime a process tries to resolve the above addresses they are routed to the address listed to the left of them (localhost) in this case.

What I do in my apps is check this host file and look for any admob entries, if I find any I notify the user that I've detected ad blocking and tell them to remove admob entries from there and do't allow them use of the app.

After all what good does it do me if they're not seeing ads? No point in letting them use the app for free.

Here is a code snippet of how I achieve that:

        BufferedReader in = null;

    try 
    {
        in = new BufferedReader(new InputStreamReader(
                new FileInputStream("/etc/hosts")));
        String line;

        while ((line = in.readLine()) != null)
        {
            if (line.contains("admob"))
            {
                result = false;
                break;
            }
        }
    } 

I vow that all ad supported apps should check this file. You do not need to be root in order to access it, but writing to it might be a different story.

Also, not sure if there is any other files that act the same on a linux based OS, but at any rate we can always check all of those files.

Any suggestions on improving this are welcome.

Also the app called "Ad Free android" needs root access, meaning that it most likely changes the hosts file in order to achieve its goal.

Solution 2:

My code for this issue is thusly: -

try {
    if (InetAddress.getByName("a.admob.com").getHostAddress().equals("127.0.0.1") ||
        InetAddress.getByName("mm.admob.com").getHostAddress().equals("127.0.0.1") ||
        InetAddress.getByName("p.admob.com").getHostAddress().equals("127.0.0.1") ||
        InetAddress.getByName("r.admob.com").getHostAddress().equals("127.0.0.1")) {
        //Naughty Boy - Punishing code goes here.
        // In my case its a dialog which goes to the pay-for version 
        // of my application in the market once the dialog is closed.
    }
} catch (UnknownHostException e) { } //no internet

Hope that helps.

Solution 3:

As developers, we need to do the difficult job of empathizing with the users and find a middle ground between punishing the few who try to take advantage and the many who play by the rules. Mobile advertising is a reasonable way to allow someone to use a functional piece of software for free. The users who employ ad blocking techniques could be considered lost revenue, but if you take a look at the big picture, can also be those who spread the word about your application if they like it. A more gentle approach to running on systems with ads blocked is to display your own "house" ad. Create one or more banner images and display them in the same spot as your normal ad with an ImageView of the same height (e.g. 50dp). If you successfully receive an ad, then set your ImageView's visibility to View.GONE. You can even create a timer to cycle through several house ads to get the user's attention. Clicking on your ad can take the user to the market page to buy the full version.

Solution 4:

Can you check to see if the ad loaded in your app?

Ad blockers work by preventing your app from downloading data. You could check the content length of the data in your ad frame to make sure there is data there.

If there is no data throw up a message and exit or warn you with an email.

It might not be as big an issue as you think since only a small percentage of people block ads.