Android tracker blocking
Last updated : 20/10/2023 (Incomplete, requires further additions)
Introduction
This is my guide on blocking ads & trackers in Android. While there are various methods available (of which I personally recommend AdAway), I will only cover AdAway, NetGuard, & TWRP at the moment of writing (20/10/2023).
Prerequisites
Required stuff :
- An Android device (with root if necessary)
- Any of these adblocker apps (don't use more than one, especially in non-rooted environment)
- AdAway (usable as either root / non-root, with the latter requiring the VPN slot)
- NetGuard (VPN-only firewall; has ad-blocking in GitHub / F-Droid builds)
- Blokada (VPN-only adblocker) (guide pending)
- Optional : VPN lockdown (for AdAway (VPN) / NetGuard)
- Settings > Network & internet > VPN
- Tap the gear button on the VPN you're using
- Enable "Always-on VPN" & "Block connections without VPN"
AdAway
Preparation guide (both VPN & root):
- Install AdAway.
- Open AdAway, preferably while the device is still not connected to the internet. At first run (which should be the case here), it will immediately ask you to choose between root-based ad-blocking & VPN-based ad-blocking.
- Root-based ad-blocking is faster & consumes less battery, although it requires root access & edits /system/etc/hosts.
- VPN-based ad-blocking can run on both rooted & non-rooted environment, but consumes more resources & doesn't allow using other VPNs.
- Once either ad-blocking method has been selected, AdAway will immediately try to apply the default sources (which will fail if AdAway doesn't have internet access). At this step, AdAway can be closed & re-opened to bypass this behavior.
- Enter Preferences by selecting the burger menu found on the bottom-left corner & toggle "Enable IPv6 support"/
- (Optional) To disable automatic updates, which is enabled by default:
- Enter Preferences by selecting the burger menu found on the bottom-left corner (skip if already in Preferences, which you should be at this point)
- Enter Automatic updates
- Uncheck "check for update at startup" & "periodically check for update" on both Application updates & Hosts updates.
- Set up your hosts sources as needed. Further notes available down below.
- Once everything is set up, connect to internet (on VPN mode, Private DNS should be disabled) & press the download button. This updates & applies the hosts file (if rooted) / VPN configuration (if using VPN mode).
- Optional, only for rooted : reboot is probably recommended after hosts is applied. Ignore if using VPN mode.
Additional steps for rooted (preferably done before setting hosts sources and/or parsing hosts) :
- Enter Preferences by selecting the burger menu found on the bottom-left corner
- Enter Root based ad blocker
- Configure IPV4 redirection to 0.0.0.0 from the default 127.0.0.1.
- Configure IPV6 redirection to :: from the default ::1.
- Uncheck the "Enable web server" toggle (optional).
Some notes regarding AdAway hosts sources :
- By default, AdAway will use these 3:
- My personal setup :
- The default included https://adaway.org/hosts.txt
- The default included https://pgl.yoyo.org/adservers/serverlist.php?hostformat=hosts&showintro=0&mimetype=plaintext
- https://raw.githubusercontent.com/StevenBlack/hosts/master/alternates/fakenews-gambling-porn-social/hosts - StevenBlack Full hosts (replaces the StevenBlack Unified Hosts)
I personally recommend using https://raw.githubusercontent.com/StevenBlack/hosts/master/alternates/social/hosts (StevenBlack unified hosts + social) as the bare minimum, especially if your only concern is privacy. However, this is my personal setup, so the full hosts go in by default.
- either https://codeberg.org/Narsil/hosts/raw/branch/master/Google/HostsGoogle or https://git.nixnet.services/Narsil/hosts/raw/branch/master/Google/HostsGoogle
This blocks Google's Play Store, NTP, GPS, & captive portal URLs; Qualcomm's IZAT; Lineage, AdAway, & SD Maid's telemetry; & a minor set of trackers. If you're using Aurora Store, whitelist play.googleapis.com & connectivitycheck.android.com.
- either https://codeberg.org/Narsil/hosts/raw/branch/master/Mozilla/Mozilla or https://git.nixnet.services/Narsil/hosts/raw/branch/master/Mozilla/Mozilla
This blocks Mozilla's services, such as network location, telemetry, & Pocket for Firefox. Will prevent Firefox-based browsers from installing and/or updating add-ons. If you're using Mozilla UnifiedNLP, whitelist location.services.mozilla.org.
- either https://codeberg.org/Narsil/hosts/raw/branch/master/Microsoft/Microsoft or https://git.nixnet.services/Narsil/hosts/raw/branch/master/Microsoft/Microsoft
Blocks connections to Microsoft. Might be unnecessary since Android doesn't generally have Microsoft telemetry (Android apps built by Microsoft may have those), but perhaps a nice addition if you don't want anyone using your device connecting to Microsoft telemetry.
- either https://codeberg.org/Narsil/hosts/raw/branch/master/Microsoft/SpyMicrosoft or https://git.nixnet.services/Narsil/hosts/raw/branch/master/Microsoft/SpyMicrosoft
Additional blocking of Microsoft's spyware.
- https://codeberg.org/GearJail/Hosts/raw/branch/main/hosts
That's my personal hosts, updated whenever I want it. Feel free to use this in your NetGuard adblock config or something like that.
- In order to simplify typing them in the future, create a backup. Open Preferences > Backup / restore block rules, then select Backup & browse to the folder where you want the backup to be. Afterwards, if you'd like to add the hosts above, you can simply use the Restore option, and select the adaway-backup.json. I also have a backup json at my my Codeberg repo.
NetGuard
Primarily meant to be a firewall / network monitor, NetGuard also offers ad-blocking in GitHub Releases / F-Droid builds.
Prerequisite :
- Advanced options (3 dot menu > Settings > Advanced options)
- Enable "Filter traffic"
- Enable "Block domain names" if not enabled (it should be by default)
Guide :
- Browse to backup settings (3 dot menu > Settings > Backup)
- For those without own hosts file / want an updatable hosts :
- Enter preferred hosts file download URL (or scroll up a bit for my hosts & apply it)
The default is https://www.netguard.me/hosts.
- Tap "Download hosts file", making sure there's internet connection (especially for NetGuard).
- For those with prepared hosts file :
- Tap "import hosts file"
- Browse to your hosts file location & select it
Copy/pasting hosts
A more direct method for setting up ad-blocking hosts without AdAway. Ideal for Fate/GO (or any root-hating game) players running custom ROMs who needs hosts-based ad-blocking ASAP, though uninstalling Magisk & all root-dependent components after applying hosts (or just using VPN-based adblocker, especially if running locked bootloader) works as well.
Guide:
- Get an ad-blocking hosts file of your choice. I provide mine in Codeberg, for example.
- Boot to TWRP or any custom recovery with file access.
- Mount /system (or /system_root depending on recovery). Make sure the recovery has rw access.
- Using the custom recovery's file manager, browse to /system/etc (or /system_root/system/etc if system as root).
- Delete the default hosts file.
- Browse to where you stored your ad-blocking hosts & copy it to /system/etc (or /system_root/system/etc if system as root).
- Browse again to /system/etc (or /system_root/system/etc if system as root) & chmod hosts file to 644.
- Unmount /system & reboot to system.
Back to top
Android Privacy Mod - Basic
Index - cellphone
Main Page