Aapo Rantalainen's blog

Experiences with Information Technology and Open source

Newer adb for Ubuntu, with sideloading

Posted by Aapo Rantalainen on March 4, 2015

Android debugging tool ADB has ‘new‘ feature called sideload, which is in use on Android devices, but not all versions of host toolset. Here comes instructions for compiling newest version from source.

Context

Adb (Android Debug Bridge) is debugging tool to communicate with Android-device and host.

Problem

Some people follow instructions and then encounters mystic error:
adb “*cannot read ‘sideload’ *”

Reason

adb in your system is too old. E.g. you are using Ubuntu/Debian and your adb comes from package android-tools-adb.

Solution

Compile your own adb (doesn’t need full Android SDK).

#Needed tools
sudo apt-get install zlib1g-dev libssl-dev git make gcc

#Download source code (this is currently the newest branch, in future it might still work without issues)
git clone -b android-5.0.2_r1 https://android.googlesource.com/platform/system/core
cd core/adb

#Create Makefile
echo -e '
# standalone Makefile for adb
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

CPPFLAGS+= -DADB_HOST=1
CPPFLAGS+= -DHAVE_FORKEXEC=1
CPPFLAGS+= -DHAVE_SYMLINKS
CPPFLAGS+= -DHAVE_TERMIO_H
CPPFLAGS+= -DHAVE_SYS_SOCKET_H
CPPFLAGS+= -DHAVE_OFF64_T
CPPFLAGS+= -D_GNU_SOURCE
CPPFLAGS+= -D_XOPEN_SOURCE
CPPFLAGS+= -I.
CPPFLAGS+= -I../include

LIBS= -lcrypto -lpthread -lrt -lz
CC= gcc
LD= gcc

OBJS= $(SRCS:.c=.o)

all: adb

adb: $(OBJS)
\t$(LD) -o $@ $(LDFLAGS) $(OBJS) $(LIBS)

clean:
\trm -rf $(OBJS) adb
' > standalone_Makefile

#Compile
make -f standalone_Makefile

#Profit
./adb sideload foobar

Adb can be tested without device connected, and with dummy filename. Error message should be then:

* cannot read 'foobar' *

Credits

Makefile starting point: http://android.serverbox.ch/?p=1217

More to read

Adb sideload feature is added:

commit 447f061da19fe46bae35f1cdd93eeb16bc225463
Author: Doug Zongker
Date: Mon Jan 9 14:54:53 2012 -0800</code>

add "adb sideload" and sideload connection state

Recovery will soon support a minimal implementation of adbd which will
do nothing but accept downloads from the "adb sideload" command and
install them. This is the client side command (mostly resurrected out
of the old circa-2007 "adb recover" command) and the new connection
state.

Change-Id: I4f67b63f1b3b38d28c285d1278d46782679762a2

But it is still not documented: https://code.google.com/p/android/issues/detail?id=158394

One Response to “Newer adb for Ubuntu, with sideloading”

  1. […] This post is upgrade for my previous post about building ADB for Ubuntu: https://aaporantalainen.wordpress.com/2015/03/04/newer-adb-for-ubuntu-with-sideloading/ […]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: