04 June 2025

Accessing an Android phone via ADB using your desktop PC running Linux

It turns out, one way to reduce the size of a Flutter app, is by splitting it into builds for each specific device architecture you want. So if you type:

flutter clean; flutter build apk --split-per-abi 

It'll give an output like:

✓ Built build/app/outputs/flutter-apk/app-armeabi-v7a-release.apk (6.9MB)
✓ Built build/app/outputs/flutter-apk/app-arm64-v8a-release.apk (7.4MB)
✓ Built build/app/outputs/flutter-apk/app-x86_64-release.apk (7.6MB) 

Now I needed to know which one I could use on my phone, and realized that in all these years, I didn't bother finding out what architecture my phone was running. 

So I activated Developer Options and USB Debugging on my phone and did the following:

sudo apt update; sudo apt install adb

Now ADB (Android Debug Bridge) should be installed. To see which devices you can connect to via ADB, type:

adb devices

You'll be asked on your phone for permission to do USB debugging. Grant it.

Now either type: 

adb shell uname -m

Or, just:

adb shell

And then type:

uname -m

And now I know the phone is armv7l, which is an ARM 32 bit architecture.

So now I know I could have also tried:

flutter build apk --target-platform android-arm --analyze-size


There are many other ADB commands:

To copy files: 

adb pull /path/to/phone/file /path/to/desktop/folder

Mount the phone onto the Linux filesystem:

sudo apt install adbfs
mkdir ~/android
adbfs ~/android

Now you can access the files via your desktop computer at ~/android

To get elevated permissions with ADB:

adb kill-server
sudo adb start-server
adb devices

For more commands, simply type:

man adb