Using ADB to Pull APKs off Device

ADB Help for pull and shell

It is sometimes helpful to pull an APK from a working device so you can install it on a different device. These commands should work on an emulator, phone, tablet, or other Android device. You just need to be able to connect with ABD.

  • Connect to device with ADB
  • View installed apps
  • Find path for APK
  • Pull/Download APK

View Installed Apps

This will display a list of all the installed packages.

adb shell pm list packages 

Find path for specific App/APK

Replace with the app of interest.

adb shell pm path

Pull APK to local machine

Pull/Download the APK of interest to your local machine with the following command. Change the path “/data/app/…” to the path returned from the previous command.

adb shell pull /data/app/info/base.apk

You can view the following link for more information.

Advanced Tricks

What if you need to get an APK off a secondary profile, or would like to download all the APKs off a system? And what about split APKs?

Multiple User Profiles

Run the following command to list the users.

adb shell pm list users

Example return

        UserInfo{0:User:a41} running
        UserInfo{11:User:439} running

In this case our second user id is 11. To get a list of APKs installed for our second user we would specify the –user= option

adb shell pm list packages --user=11

To get the path for the app we would run it with

adb shell pm path --user=11

Split APKs

Split APKs can be slightly more difficult to manage, mainly due to the fact that there are multiple APKs to keep track of.

When you run the “pm path” command, it should return multiple APKs. Use the pull command like normal, but download each APK.

You’ll need to use a split APK installer to install all the APKs.

PowerShell script for Pulling/Downloading all APKs on Device

The following PowerShell script will download all APKs for a specific user and put them in their own folders.

  • Copy the contents to a .ps1 file
  • Enable ps1 execution policy if not already enabled
  • Run PowerShell script.

This script will pull all the APKs off of a device and put them in the current folder.
It will also download split APKs.

# adbapkbackup uses adb to get a list of all the APKs you have on a phone and then
# Creates folders for each app and downloads the APKs for those apps.

# Copy and save code as a ps1 file

# Enable ps1 scripts to run on your computer by launching an Admin promopt and running
# set-executionpolicy remotesigned

# If you are in a secondary profile, add and/or modify
#  "--user 15"
# to your user id
# adb shell pm list users

# If in secondary profile, add "--user 15" after packages before > apklist.txt
adb shell pm list packages --user 15 > apklist.txt

 $apks = ((Get-Content .\apklist.txt)) -replace 'package:',''

 ForEach ($apk in $apks) {
    echo "APK is $apk"
    md $apk
    # If in secondary profile, add "--user 15" after path, before $file
    adb shell pm path $apk
    $filepath = ((adb shell pm path --user 15 $apk | % {$_.replace("package:","")}))
    ForEach ($lapk in $filepath | % {$_.replace("package:","")}) {
        echo "pulling $lapk $apk"
        adb pull $lapk $apk

no permissions (user in plugdev group; are your udev rules wrong?)

While trying to use ADB on a Linux Computer, I received the following error from “adb devices”

no permissions (user in plugdev group; are your udev rules wrong?);

Not exactly sure what causes the above error, but the information in the following Stack Exchange link was helpful.

I was able to get around the issue by putting the USB option to “File Transfer Mode” from the notifications menu

How to Restore Pixel to Factory Image

Restoring a Pixel to the factory image is a pretty straight forward operation if you are familiar with fastboot and adb. This guide assumes you have fastboot already installed and setup in your user path. If not you can refer to the following link for more information.


1. Download OTA Image

Go to the following link and download the Factory Image for your device

Extract the file and then open a terminal or command prompt in that directory.

2. Boot up Pixel in recovery

You can do this with “adb reboot recovery” or with the volume key to boot into the Android boot menu.

3. Flash Image

On Windows you can flash the firmware with


Or on Linux


Should take it a couple of minutes to complete.

Next we can lock bootloader with

fastboot flashing lock

You will need to confirm the lock on your phone.

Android Button – Remove Shadow and Border from Button with Image on it

We can remove the border and shadows from a button by adding the following style code in your activity_main.xml file. Or what ever your XML file is.


Code for button. We are setting an image as the background.


Comparison of buttons. One on the left still has the shadow on it

Difference between border and borderless buttons

More info here

Getting Android WiFi state in Kotlin

In Kotlin you can request if the WiFi adapter is on or off with the following code
This changes the text on a textbox, replace with your textbox.

wifiManager = this.applicationContext.getSystemService(Context.WIFI_SERVICE) as WifiManager
textBox.text = "WiFi State = ${wifiManager.wifiState}"

The important part is


It will return a number from 0-4 which indicates if it is on or off.

0 = WiFi is being disabled
1 = WiFi Disabled
2 = WiFi is being enabled
3 = WiFi is Enabled
4 = Error

Add ADB path to Windows Environment Variables

From the start menu search for “Edit environment variables for your account”

Click Path and then Edit.

Edit Environment Variables

Then click new and paste in the path to the ADB directory which should be


And hit OK

Adding ADB path

You should be good now. You’ll need to relaunch and Command Prompts you have open, but you should be able to run adb without having to navigate to the adb folder.

You need to use a Theme.AppCompat theme (or descendant) with this activity.

You need to use a Theme.AppCompat theme (or descendant) with this activity.

Looks like if you get the above error resolved by adding the following to the Android Manifest file.


Kotlin – Buttons and TextViews

Set Text for text view

val textBoxVar: TextView = findViewById(
textBoxVar.text = "Hello World!"

Button clicked – do something

val buttonVar: Button = findViewById(
buttonVar.setOnClickListener {
    buttonVar.text = "Button Pushed..."  //Change text on button


Toast notification

val text = "Hello World! This is a toast message!"
val duration = Toast.LENGTH_SHORT
val toast = Toast.makeText(applicationContext, text, duration)