I want to use ADB (Android Debug Bridge) on my Raspberry Pi.

How can I setup it up?

  • 3
    You want ADB command? Do sudo apt-get install android-tools-adb Nov 20 '16 at 23:05
  • I just did sudo apt-get install adb and it got installed and works! maybe they added a support for it since this question's data. May 24 '18 at 21:42

I ran accross this problem 1-2 years ago and after a long search I ended up compiling adb myself. Also, because the available adb binaries are outdated. I needed adb v1.0.32 and I could find only v1.0.29. Other adb binaries I found did not work because they were build for other CPU platforms (i.e. not ARM).

So lets compile adb on the Raspberry Pi itself - without any cross-compiling madness. It was actually easier than you'd think. All you should need is git and gcc (and the package libssl-dev, which is installed by the bash script).

Using some steps from here I made the following 2 files

  1. adb-compile-env-setup.sh

    # some steps found here: http://android.serverbox.ch/?p=1217
    sudo apt-get install libssl-dev
    mkdir ~/adb-dev/5.1.1
    cd ~/adb-dev/5.1.1
    mkdir system
    mkdir external
    cd system/                
    git clone -b android-5.1.1_r1 https://android.googlesource.com/platform/system/core
    git clone -b android-5.1.1_r1 https://android.googlesource.com/platform/system/extras
    cd ../external/                 
    git clone -b android-5.1.1_r1 https://android.googlesource.com/platform/external/zlib
    git clone -b android-5.1.1_r1 https://android.googlesource.com/platform/external/openssl
    git clone -b android-5.1.1_r1 https://android.googlesource.com/platform/external/libselinux
    cd ../system/core/adb
    cp ~/adb-dev/Makefile .
    echo "Ready to hit *make* now and pray?"
    read -rsp $'Press any key to continue...\n' -n1 key
  2. Makefile (place into ~/adb-dev/Makefile)

    # standalone Makefile for adb
    # found on: http://android.serverbox.ch/?p=1217
    # this works with android-5.1.1_r1
    SRCS+= adb.c
    SRCS+= fdevent.c
    SRCS+= adb_client.c
    SRCS+= commandline.c
    SRCS+= console.c
    SRCS+= file_sync_client.c
    SRCS+= get_my_path_linux.c
    SRCS+= services.c
    SRCS+= sockets.c
    SRCS+= transport.c
    SRCS+= transport_local.c
    SRCS+= transport_usb.c
    SRCS+= usb_linux.c
    SRCS+= usb_vendors.c
    SRCS+= adb_auth_host.c
    VPATH+= ../libcutils
    SRCS+= socket_inaddr_any_server.c
    SRCS+= socket_local_client.c
    SRCS+= socket_local_server.c
    SRCS+= socket_loopback_client.c
    SRCS+= socket_loopback_server.c
    SRCS+= socket_network_client.c
    SRCS+= load_file.c
    VPATH+= ../libzipfile
    SRCS+= centraldir.c
    SRCS+= zipfile.c
    VPATH+= ../../../external/zlib/src
    SRCS+= adler32.c
    SRCS+= compress.c
    SRCS+= crc32.c
    SRCS+= deflate.c
    SRCS+= infback.c
    SRCS+= inffast.c
    SRCS+= inflate.c
    SRCS+= inftrees.c
    SRCS+= trees.c
    SRCS+= uncompr.c
    SRCS+= zutil.c
    CPPFLAGS+= -I.
    CPPFLAGS+= -I../include
    CPPFLAGS+= -I../../../external/zlib
    CPPFLAGS+= -I../../../external/openssl/include
    # so well, let's fake HAVE_OFF64_T, because Raspbian does not.
    # just stay away from files larger than 2GB, ok?
    CFLAGS+= -O2 -g -Wno-unused-parameter -DHAVE_OFF64_T
    LIBS= -lcrypto -lpthread -lrt
    # old cross-compiler stuff 
    #TOOLCHAIN= /opt/poky/1.5/sysroots/x86_64-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi/arm-poky-linux-gnueabi-
    #CC= $(TOOLCHAIN)gcc
    #LD= $(TOOLCHAIN)gcc
    TOOLCHAIN= /usr/bin/
    CC= $(TOOLCHAIN)gcc
    LD= $(TOOLCHAIN)gcc
    OBJS= $(SRCS:.c=.o)
    all: adb
    adb: $(OBJS)
        $(LD) -o $@ $(LDFLAGS) $(OBJS) $(LIBS)
        rm -rf $(OBJS)

Run the first bash script directly on your Raspberry Pi. Once it is finished, run make. This should compile the adb binary right on the Pi using Android 5.1.1 R1 sources - no cross-compiling environment needed!

Remark: My comment in the Makefile

# so well, let's fake HAVE_OFF64_T, because Raspbian does not.
# just stay away from files larger than 2GB, ok?

I have never tested the "2GB problem", so I don't know how my adb build will behave, i.e. when you do adb push verylarge4GBfile.img. Maybe files larger than 2GB will work nonetheless - maybe not. Please let me know if you ever come across any problems in regards to this possible limitation.

I am running my adb binary on around 20-30 Raspberry Pi (v2 and v3) without any problems since approx. 2 years. It is used on a variety of android phones, but mostly android 4.4.x and android 5.1.x phones. Especially adb forward is working perfectly (which was not available in adb v1.0.29 as far as I remember). adb push with ~1GB files works fine too.

  • When I was testing this solution what I did was just copy and pasted above 2 scripts and executed. An error occurred "Makefile:79: *** missing separator. Stop." : Solution - Replace leading spaces with tabs of line 79 & 82 Feb 6 '18 at 7:38
  • If you run adb-compile-env-setup.sh script as itself, you are required to make the adb-dev sub-directory inside the home sub-directory. Feb 6 '18 at 8:09
  • 1
    If an error like "make: *** No rule to make target 'adb.o', needed by 'adb'. Stop." occurred, make sure that Makefile is inside the system/core/adb/ (This directory structure should be created after running the adb-compile-env-setup.sh) Feb 6 '18 at 8:13
  • After compiling it successfully, it still wasn't finding the devices. I had to run the adb binary with sudo and that fixed it.
    – Rusty
    Jul 17 '18 at 18:02

This thread from the XDA Forums ("ADB for Raspberry Pi") might be helpful; a user there managed to compile ADB and produced a binary for it.

The binary itself can be downloaded from this page.

After unpacking using p7zip -d <file.7z> and copying the binary file mypart/out/host/linux-armv6l/bin/adb to /usr/bin it seems to be working fine on a RPi.

(I didn't have much time to compile it myself just for the test, but instructions should be on the page mentioned above)

  • That first link is from 2012. Do you think it still has working info? Nov 20 '16 at 22:55
  • This answer is not up to date, links seams dead ...
    – snoob dogg
    Feb 21 '18 at 17:11

You can use Ubuntu Mate on Raspberry Pi., and install adb. It works. I used it two days ago, and all my 3 devices got detected (Samsung S6, MotoX, Samsung Alpha).

  • Hope it worked ! It has to. If it worked, Upvote and confirm my answer as well, Thanks !
    – D-Inker.
    Jun 10 '16 at 4:00
  • Nah, I like Raspbian. Why would I install Ubuntu Mate? Sep 13 '16 at 22:27

As for now, there are packages android-tools-adb, android-tools-adbd, android-tools-fastboot, android-tools-fsutils, android-tools-mkbootimg available for Raspbian. To me these were enough.

  • Do you mean to install all of these packages from the "Raspberry Pi OS" repository with apt install? Could you please add this to the answer?
    – Ingo
    Jun 20 '20 at 19:09
  • 2
    Exactly. The command to do it is apt install android-tools-adb android-tools-adbd android-tools-fastboot android-tools-fsutils android-tools-mkbootimg
    – yakovpol
    Jul 7 '20 at 14:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.