Gopacket for Android is a project that enables cross-compiling Go code that uses Google's gopacket library for ARM Android devices on rooted devices.
- To dynamically compile ELF binaries for Android, you have to use the Native Development Kit (NDK). The NDK is designed for C/C++ code.
- The Go build tools provide a lot of functionality. Cgo and a variety of Go environment variables allows devlopers to gain greater control over how Go compiles their code.
- Libpcap does not exist on Android. We need to cross-compile both libpcap from source and our Go code together in order for gopacket to work on Android.
Consult XDA-Developers and the Googlez for assistance if you are unfamiliar. Difficulty varies across devices and OS versions.
- Simply run
make
to build, copy, deploy, and run your Go code. Your Go code should be placed in thego/
folder. An examplemain.go
file has been provided.