Android tracker blocking
Last updated : 27/2/2023 (Incomplete, requires further additions)
Introduction
This is my guide on blocking ads & trackers in Android. Due to the various methods available (of which I personally recommend AdAway), I will only cover AdAway & TWRP at the moment of writing (27/2/2023).
Prerequisites
Required stuff :
- An Android device (cellphone / tablet) (with Magisk installed for root if necessary)
- Any of these adblocker apps (don't use more than one, especially in non-rooted environment)
- AdAway (usable in both rooted & non-rooted environment; with the latter requiring the VPN slot)
- NetGuard (VPN-only firewall; has ad-blocking in GitHub / F-Droid builds)
- Blokada (VPN-only adblocker)
AdAway
Preparation guide (both VPN & root):
- Install AdAway.
- Open AdAway, preferably without connecting the device to any networks. At first time open (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
- 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 & press the download button. This updates & applies the hosts file (if rooted) / VPN configuration (if using VPN mode).
- Optional : For rooted environment, reboot is probably recommended after hosts is applied.
Additional steps for rooted (preferably done before setting hosts sources) :
- 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
- 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.
- https://gitlab.com/Jorgu81/hosts/raw/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.
- https://gitlab.com/Jorgu81/hosts/raw/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.
- https://gitlab.com/Jorgu81/hosts/raw/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.
- https://gitlab.com/Jorgu81/hosts/raw/master/Microsoft/SpyMicrosoft
An additional blocking of Microsoft's spyware.
- 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.
Copy/pasting hosts
A more direct method for setting up ad-blocking hosts without AdAway. Ideal for Fate/GO players running custom ROMs who needs hosts-based ad-blocking ASAP, though uninstalling Magisk & all root-using components after applying hosts (or just using AdAway VPN if you're 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. 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
Index - cellphone
Main Page