Android phone to try to develop

Use your Android phone to view and edit Excel files, PowerPoint files and connect slide presentations and other office machines way surely we have some understanding. Today, tell us about how to use the Android software development.

Termux

Android software development using the most important tool is a command-line terminal. Termux is one of the most feature-rich, ecological best command line terminal.

Termux can be installed by F-Droid directly download the apk file, or downloaded from the Google Play Store.

Termux

Termux included with the package manager, can download popular Linux command-line tools such as openssh, wget, curl, git, clang, ninja and so on.

pkg install openssh wget curl git clang ninja

Hacker's Keyboard

With the command line, you can enter the command, but the law does not seem to enter the up and down keys, not the Ctrl key, enter the command inconvenient. This time can be installed Hacker's Keyboard input method. This input method contains all the keys on the PC keyboard.

Hacker's Keyboard

Hacker's Keyboard(2)

If you use the phone and I happened to be the same as the BlackBerry Key² have a physical keyboard, you can modify ~ / .termux / termux.properties file, add the missing symbols in Termux. Detailed reference here .

extra-keys = [ \
['~','`','$','%','^','&','=','|','BACKSLASH'], \
['ESC','<','>', '{', '}','HOME','UP','END','PGUP'], \
['TAB','CTRL','ALT', '[', ']','LEFT','DOWN','RIGHT','PGDN']]

OpenSSH

OpenSSH is Termux in will install the software, you can start after installing SSH server and SSH client such as PuTTY by remote control handset, and through the SCP client such as WinSCP Termux access internal data and SD card directories on your phone. You can open SSH connections to other servers remotely from your device.

After installation, you can run sshd. Login required to configure the public and the usual Linux as in ~ / .ssh / authorized_keys in.

Termux by Termux: Widget -line operation becomes Android Widget on the desktop for easy selection command to execute some user-defined. sshd should be an essential item.

micro

Termux comes with a text editor vi. If you are unfamiliar with vim and emacs, Micro is a good command-line text editor. Installation is as follows:

pkg install micro

micro

Very simple to use, finger tap to move the cursor to a specified location, Ctrl + S to save, Ctrl + Q quit, Alt + G to display commonly used commands, Ctrl + G to display help.

Note that the default mode is not soft wrap. Further input is' "([symbol characters such will automatically enter the pairing modifications to these configurations proposed modifications addresses ~ / .config / micro / settings.json, the following can modify the contents of the corresponding row.:

"autoclose": false,
"softwrap": true,

In addition, when the default SSH connection micro can not copy and paste because the cursor is micro occupied. At this time, pressing the Shift key may then copy and paste, such as holding down the Shift key in the mouse PuTTY select Copy, Paste Shift-right mouse button.

nnn

nnn is a command line file manager on Termux, it can be used to quickly jump folder.

Mounting

pkg install nnn

nnn

Common operations include move the cursor up and down arrows, into the parent folder left arrow, right arrow or cursor enter into the file currently open file or folder, Q quit, Ctrl + G enters and exits the current folder. Note Ctrl + G function requires configuration . You need to add the following function in ~ / .bash_profile of:

n()
{
    export NNN_TMPFILE=${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.lastd

    nnn "$@"

    if [ -f $NNN_TMPFILE ]; then
            . $NNN_TMPFILE
            rm -f $NNN_TMPFILE > /dev/null
            pwd >&2
    fi
}

Termux: API

Termux: API can achieve some automation Android features, but the most important function is to synchronize the clipboard between PC and Android devices.

Installation: run in Termux after the first download to install apk

pkg install termux-api

Android can display the contents of the clipboard terminal following command via SSH

termux-clipboard-get

Specify the content can be set to the Android clipboard execute the following command through SSH

termux-clipboard-set <内容>

clang

clang of normal use and the same. Termux does not support gcc, usually using clang compiled. Note that Termux the system libc ++ library does not support static library, dynamic library only supports the standard C library Bionic. Although the use of cross-platform compiler and musl libc can compile a program capable of running on Termux, but there are some problems . Termux does not support glibc.

Mounting

pkg install clang llvm lld

Mono

mono no support package. But there are community versions, such as the author compiled termux-mono and some versions running Arch Linux and Ubuntu PRoot running. The following is the latest version termux-mono, no PRoot can be run directly.

termux-mono

Android App Development

Although Termux no JDK, Android SDK and Android NDK, but can still Android App Development. Wherein ecj JDK may be used instead of, Android SDK can be used independently of dx, aapt and apksigner place, Android NDK clang may be used instead. Using these software can generate .so file, .dex .apk file and file by calling the command line.

Mounting

pkg install ecj dx aapt apksigner

Note that, Android SDK API 28 introduced d8 now also do not support , so the compiler Java 8 and later versions of the code would be more difficult.

Wcode

Internal Termux view and edit the code is not convenient; Termux the file can not be viewed and edited outside of the App; SDCard simulation partitions usually do not support executing authority FAT32 format code in which very inconvenient.

So some people think Termux by running in a server, and then edit the file in an external server connection method . In order to achieve similar to the Visual Studio Code editing experience, he directly used Visual Studio Code of Monaco Editor , run by a HTTP server nodejs in Termux in and accessed in a browser. His code here . But the effect is relatively poor, only suitable for running on the tablet.

Behind someone has done a similar program, is wCode .

Mounting

pkg install nodejs
npm install -g wcode

The author of Wcode made some modifications , fixes some bug, and make it better able to run on the phone.

Wcode

Wcode(2)

Fast input

Many commonly used commands long, enter the same, can be abbreviated by bash alias.

Open ~ / .bash_profile, to increase the alias command. Author's alias command as follows:

alias cg=termux-clipboard-get
alias cs=termux-clipboard-set
alias m=micro
alias i='ifconfig | grep '\''inet '\'' | sed '\''s/ *inet//g'\'' | cut -d'\'' '\'' -f2'
alias p='ping www.bing.com'
alias w=wcode

Where i is the current IP address.

After exiting Termux re-entry, you can run the program by short commands.

Guess you like

Origin www.cnblogs.com/Rex/p/11444455.html