Mobile Security4 min read

Extract an APK from an Android phone in one command

getAPK pulls an installed app off your Android phone over adb as one APK, or an APKS bundle for split apps. No root needed. What you need and how to use it.

Getting an app off an Android phone sounds like one command: adb pull. In practice it’s several. You find the package name, ask the phone where the app is installed, discover there are four files rather than one, pull each of them, and work out how to keep them together. Skip a step and you end up analysing half an app.

We built getAPK to do all of it in one command. It’s free and open source, and it’s the Android counterpart of getIPA.

What you need

  • An Android phone with USB debugging turned on. No root needed.
  • A computer running macOS, Linux or Windows, with Python 3.9 or newer
  • Android platform-tools, so that adb is on your PATH (or you can point getAPK at it with --adb)

To turn on USB debugging, open Settings → About phone, tap Build number seven times to unlock Developer options, then switch on USB debugging in Developer options. Connect the phone and accept the prompt that asks you to allow USB debugging from your computer. The exact menu names vary a little between manufacturers.

Only use it on apps and devices you own or are authorised to test.

Install

pipx install getapk

That’s it. getAPK has no Python dependencies, and it doesn’t install anything on the phone. If you’d rather read the code first, it’s on GitHub.

Use it

Start by listing the apps you’ve installed:

getapk --list

You get each package name, its version and the app that installed it (com.android.vending is the Play Store):

  1. com.example.app                                         2.4.1          com.android.vending
  2. com.example.notes                                       1.8.0          com.android.vending

Example output.

Then pull one by its package name:

getapk com.example.app -o ./apps
[+] com.example.app 2.4.1 -> ./apps/com.example.app-2.4.1.apks  (4 splits, 4.9 MB)
    sha256 1151750e38fe4bbbd568818e3ac9dfbfc37f65359a7fcb909cfc1b6bf966e77d

Example output.

Each pulled app gets one line with where it was saved, how many files it was made of and its size, followed by its SHA-256. Keep the hash with your notes so you can show later exactly which build you looked at.

Why one file matters

Most apps from the Play Store aren’t installed as a single APK. They’re installed as split APKs: a base.apk with the app’s code and manifest, plus extra files for the phone’s CPU architecture, language and screen density. Native libraries often live in one of those splits, not in the base.

A plain adb pull of base.apk gives you something that won’t install on its own and is missing those libraries and resources. getAPK asks the phone for every file the app is made of, pulls them all, checks each one is a real APK, and writes a single file:

  • Single-APK apps become <package>-<version>.apk
  • Split apps become <package>-<version>.apks, a zip holding base.apk first and then every split

The .apks file keeps the whole app together, so the next tool sees everything the phone sees. If a tool you use needs one APK per file, unzip the .apks and the individual APKs are inside.

Handy options

getapk --list -m shop                  # only packages containing "shop"
getapk com.example.app com.example.notes   # several apps in one go
getapk --all -o ./apps                 # every app you installed
getapk --all --include-system          # include preinstalled apps too
getapk -s SERIAL com.example.app       # choose a phone when several are connected
getapk --format apks com.example.app   # always write an .apks bundle

--format apk does the opposite: it insists on a single .apk, and refuses a split app with a clear message instead of quietly giving you only the base:

[-] com.example.app: com.example.app is a split-APK app (4 files); use --format auto or apks

Example output.

When something isn’t ready, getAPK says what to fix. With no phone connected it asks you to connect one with USB debugging enabled. If the phone shows as unauthorised, it tells you to unlock it and accept the USB debugging prompt. With two phones connected, it lists them and asks you to pick one with -s.

What it can’t get

getAPK copies the app as installed: its code, manifest, resources and native libraries. It doesn’t copy the app’s data, such as its databases, preferences and cached files. Android keeps those in a private folder that adb can’t read without root, and that’s by design. Our guide to extracting Android apps explains what you can and can’t reach, and why.

Safety

getAPK runs on your computer and talks only to your phone, through adb. There’s no telemetry.

It also treats the phone as untrusted. Package names, device serials and every path the phone reports are checked before they’re used. Nothing is passed through a shell on your computer, and the only app-specific input sent to the phone is a checked package name. Output file names are cleaned, so a hostile device can’t write outside your output folder. Files are written to a temporary folder and only moved into place once they’re complete.

Apps may be copyrighted. Extraction is for your own security analysis, not for redistributing someone else’s app.

What to do with the APK

The APK is the starting point, not the result. Our free tool AppSleuth reads .apk and .apks files directly:

appsleuth scan apps/com.example.app-2.4.1.apks

It looks for secrets, network security configuration, exported components, weak cryptography and more, and writes a report you can work through. Part 1 of our AppSleuth series shows how to read it. For what to look for beyond the package, such as secrets stored inside the app, see our mobile app penetration testing guide.

Get it

One practical security note a week.

No spam. Unsubscribe any time.

Need a pentest for an audit, a customer, or peace of mind?

Tell us what you need tested. You’ll get a fixed-fee proposal with tester-days and timeline stated, usually within a few days of the scoping call.