Understanding what data your apps send and receive can help you spot privacy leaks, debug connectivity problems, or verify that a VPN is actually routing traffic. Unlike desktop operating systems, Android does not expose a built‑in packet sniffer, so you need a lightweight, command‑line tool that works on the device itself.
This tutorial shows how to use Termux – a terminal emulator and Linux environment for Android – together with tcpdump to record packets from a single app. The method works on Android 8‑13 without requiring root access. Because the capture runs under the app’s own UID, you only see traffic that belongs to that app, which is usually enough for privacy checks and debugging.
$ prompt appears.pkg update && pkg upgrade -ypkg install wget curl proot-distro -y.pcap file):
termux-setup-storage
You will see a system dialog – tap Allow.Why these steps matter: updating ensures you get the latest binaries, and termux-setup-storage creates a /storage/emulated/0/ shortcut inside Termux, making it easy to move files to your PC later.
Termux’s package repository does not ship tcpdump because it needs raw socket access, which is restricted on non‑rooted devices. However, a pre‑compiled, non‑root version exists that works when launched via the app’s own UID. Follow these steps:
wget inside Termux:
wget -O $HOME/tcpdump https://github.com/karjona/tcpdump-android/releases/download/v4.9.3/tcpdump-arm64
Replace arm64 with arm if your device uses a 32‑bit CPU.chmod 755 $HOME/tcpdump$HOME/tcpdump -h
You should see the usage message. If you get Permission denied, double‑check the chmod command.Note: This binary captures only traffic that the invoking UID can see. That means you can capture packets from the app you run run-as on, but you cannot see system‑wide traffic without root.
You need the exact Android package identifier (e.g., com.whatsapp) to run the capture under that app’s UID.
adb shell pm list packages | grep -i partial_name
Replace partial_name with a word from the app’s name.Write down the package name – you will need it in the next step.
run-asThe Android run-as command lets you execute commands as if you were the app itself, provided the app is debuggable. Many popular apps are not debuggable by default, but you can still capture traffic from any app that you have installed from the Play Store by using the adb shell run-as trick when the device is in developer mode. If the app is not debuggable, the method will fail, and you will need root or a VPN‑based capture tool.
adb devices
You should see your device listed as device.com.example.app with your package name):
adb shell
run-as com.example.app
If the command returns a prompt that looks like app@com.example.app:/data/data/com.example.app$, you are now running as that app.tcpdump and write the capture to a file in the app’s private storage (which is accessible to Termux via the shared storage path):
cd /sdcard/Download
/tcpdump -i any -s 0 -w capture.pcap
The -i any flag tells tcpdump to listen on all interfaces the app can see; -s 0 captures the full packet; -w writes to capture.pcap.After stopping, you will have a capture.pcap file stored in /sdcard/Download. Because the file lives in shared storage, Termux can access it later.
adb pull /sdcard/Download/capture.pcap ~/Desktop/
This copies the file to your desktop folder.scp or a cloud sync app. Example:
mv /sdcard/Download/capture.pcap $HOME/
termux-share capture.pcap
The second command opens Android’s share sheet, letting you send the file via email, Google Drive, etc.Now you have a standard PCAP file that any network analyzer can read.
Wireshark provides a graphical interface to filter, decode, and visualize packets.
capture.pcap.http.host == "api.example.com"
Or filter by IP address:
ip.addr == 93.184.216.34Transport Layer Security → Handshake Protocol: Server Name.By inspecting the filtered view you can answer questions such as:
run-as using a VPN‑based appIf the target app is not debuggable, the run-as method will fail with run-as: Package 'com.example.app' is not debuggable. In that case you have two practical options:
tcpdump binary with su. Rooting is outside the scope of this tutorial because it voids warranties and may brick devices.Both alternatives are mentioned here so you can decide which path matches your risk tolerance.
run-as reports “package not debuggable”Most production apps are built with android:debuggable="false". You can only use run-as on apps you have built yourself (e.g., a test version of the target app). To work around this:
adb install -t flag).android:debuggable by modifying the APK with apktool, but this requires re‑signing and is not recommended for casual users.Even with run-as, the binary may need the CAP_NET_RAW capability, which is granted only to root. The pre‑compiled binary used in this guide is built with the --disable-suid flag to work under a normal UID, but it still fails on some OEM‑restricted ROMs. If you encounter this:
--interface any flag omitted; some devices expose lo only.This usually means the app’s traffic is encrypted inside a VPN tunnel or uses QUIC over UDP, which the simple tcpdump build may not see on the any interface. To capture QUIC:
-i any udp port 443).Make sure the capture was written with -w. If you used -c (capture count) without -w, tcpdump prints packets to stdout, which Termux may have discarded. Re‑run the capture with the proper -w flag.
.pcap file in an encrypted folder or delete it after analysis.adb shell run-as <package> to switch to the app’s UID.tcpdump -i any -s 0 -w capture.pcap while you exercise the app..pcap file to your computer.Following these steps gives you a reproducible, no‑root method to peek inside an Android app’s network behavior. The same pattern can be reused for any app you develop or audit, making it a valuable addition to your Android troubleshooting toolkit.









