From 189cff2fe3a3b0932a2cb656109baa3f3d9fe37e Mon Sep 17 00:00:00 2001 From: "Martin A. Brown" Date: Tue, 15 Mar 2016 09:53:48 -0700 Subject: [PATCH] Updated Linux-Android HOWTO from Guido Gonzato Hello Martin, I've been lurking on the discuss list and have fixed the text following some suggestions I received. Please find attached the final version of my proposed Howto; I hope it's going to be accepted. All the best, Guido =8-) --- LDP/inprogress/Linux-Android-HOWTO.sgml | 109 ++++++++++++++++++------ 1 file changed, 84 insertions(+), 25 deletions(-) diff --git a/LDP/inprogress/Linux-Android-HOWTO.sgml b/LDP/inprogress/Linux-Android-HOWTO.sgml index eb0e410c..79f1eea6 100644 --- a/LDP/inprogress/Linux-Android-HOWTO.sgml +++ b/LDP/inprogress/Linux-Android-HOWTO.sgml @@ -55,14 +55,31 @@ OS X only, but a GNU/Linux system is perfectly capable of interacting with Android devices. With a bit of hacking, as usual.

-In the following, I will share a few tricks I have collected. I work -on a GNU/Linux Mint box, but I'll try and be distribution-agnostic. -I'll concentrate on Free and Open Source Software (FOSS) whenever -possible, and I'll take standard, unrooted Android devices into -account. By the way: ``rooting'' means tweaking your Andbox to gain -root permissions, as you would do in Linux with sudo. -``Unrooted'' means ``not tweaked''. +In the following, I will share a few tricks I have collected: + + + using the Android Debug Bridge; + understanding and using the Android file system; + installing programs from other markets; + copying and syncing files and directories; + backing up stuff; + using a terminal emulator; + compiling native command-line programs; + remote control to/from Android; + and more. + + + +

+I work on a GNU/Linux Mint box, but I'll try and be +distribution-agnostic. I'll concentrate on Free and Open Source +Software (FOSS) whenever possible, and I'll take standard, unrooted +Android devices into account. By the way: ``rooting'' means tweaking +your Andbox to gain root permissions, as you would do in Linux with +sudo. ``Unrooted'' means ``not tweaked''. + +

Since Android is very fragmented (hey, it's Linux after all!) and several versions are available, I'll just provide information that is applicable to what I own: Android 4.0.4, 4.1.1, and 5.0.1 on ARM @@ -207,6 +224,7 @@ edit the file: /etc/udev/rules.d/50-android.rules +

(create a new file if it's missing) and add this line: @@ -525,7 +543,8 @@ suggestions are:

is a ``real'' keyboard that provides arrow keys, Esc, Alt, Ctrl, and - so on. Released under the Apache License 2.0. + so on; you really can't do without it if you plan to use a terminal + emulator. Released under the Apache License 2.0. Ghost Commander: @@ -553,7 +572,8 @@ emulator and BusyBox, . The latter is a single executable that provides the functionality of several commands that you normally expect to find in any self-respecting Unix box, but that are missing -in Android. +in Android. cp and tar are the first that spring to +mind.

In Section @@ -628,18 +648,20 @@ An Andbox can easily share its installed programs with another device, provided that the Android versions are compatible. All you need is Ghost Commander. +

From the ``Home'' position, select ``Applications'' to get a list of installed .apks ; click on the one you want and copy it to a standard folder (say, /mnt/sdcard.) From this location, long press on the program .apk and select ``Send To...''. Now select Bluetooth, which is probably the easiest way to send the APK to Alice; or choose another method from Section below. +name="Copying Files"> below. If your device refuses to send a +.apk file via Bluetooth, just rename or zip it before sending +it, then unpack it or rename it back on the new device.

-If your device refuses to send a .apk file via Bluetooth, -just rename or zip it before sending it, then unpack it or rename it -back on the new device. +From within the Ghost Commander, tap on the .apk file to +install the program. When done, you can delete the .apk. @@ -1057,8 +1079,8 @@ the same.

If you need a more complete command-line experience, you will also -want to install a command-line environment like KBOX, ZShaolin or -Terminal IDE: +want to install a command-line environment like KBOX, ZShaolin, +Terminal IDE, or Termux: @@ -1091,12 +1113,13 @@ Terminal IDE: +

It's a very complete Linux-like command-line environment. It's focused on development, providing Vim, gcc, mc, ssh, and loads of software. Once installed, it gives you the option ``Install System'' to install additional components, including the bash shell. - +

@@ -1110,6 +1133,31 @@ that you install Terminal IDE: it provides a very Linux-like experience. If you're short on storage, I suggest that you install KBOX: it's a very good compromise. +Users of Android 5 and later versions may want to install an +alternative terminal emulator called Termux: + +

+ + +

+It's very nice and self-contained, i.e. it does not need KBOX or +another command-line environment. Additional software can be installed +simply using apt (Debian users, does that ring a bell?): + + + +$ gcc +The program 'gcc' is not installed. Install it by executing: + apt install gcc +$ ... + + + +

+Termux is released under GPLv3, but some add-ons are available for a +small fee. + + Installing KBOX @@ -1316,9 +1364,9 @@ url="http://arachnoid.com/android/SSHelper/" name="http://arachnoid.com/android/SSHelper/">

-Since it runs on -unrooted devices, it uses the port 2222 instead of the standard port -22; i.e., to connect to it from the Linux terminal you will do: +Since it runs on unrooted devices, it uses the port 2222 instead of +the standard port 22; i.e., to connect to it from the Linux terminal +you will do: @@ -1386,6 +1434,7 @@ toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86/bin/ contains prebuilt binaries: include that directory in the $PATH. +

The compiler is called arm-linux-androideabi-gcc. You use it instead of gcc to compile Android binaries. In general, all binutils have a arm-linux-androideabi- prefix. @@ -1441,7 +1490,12 @@ Linux:~$ _ Beware: Android 5.* has better security policies and will not allow running programs from /data/local/tmp, or even accessing that directory. From the terminal, you'll have to copy the compiled -programs elsewhere. For instance, using KBOX: +programs to a directory where you have write and execute permissions. +Beware: you will have to copy files in the blind, specifying their +exact names, no wildcards allowed! + +

+For instance, using KBOX: @@ -1451,13 +1505,13 @@ kbox$ cp /android_root/data/local/tmp/hello . kbox$ ls hello kbox$ ./hello -hello, workd! +hello, world! kbox$ _

-A remarkable list of command-line programs can be compiled for +A remarkable list of command-line programs can be easily compiled for Android. Among others, I ported the Bywater BASIC interpreter:

@@ -1465,7 +1519,13 @@ Android. Among others, I ported the Bywater BASIC interpreter: name="http://sourceforge.net/projects/bwbasic/">

-the C version of the e3 text editor: +(minor tweaks were needed: I added -DHAVE_ISNAN=1 to the DEFS +in the Makefile, and also #define uint64_t unsigned +long at the top of bwbasic.h) + +

+The C version of the e3 text editor (version 2.7.1) can be compiled +with no tweaks at all:

-and the ABC music tools: +same for the ABC music tools:

. -

Compile the programs you need, copy them to /data/local/tmp/, and make sure this directory is included in the $PATH of your