Android, using terminal for disovering connected device

Hello everybody,

Here is a quick article how to:
1. Install apk into Android device;
2. Uninstall applications;
3. Discover device’s filesystem;
4. Open and read files;
5. Copy files onto device.

Prerequisites:
First of all you need to connect to the device’s operational system shell, use your Terminal for this purpose and type:

~$ adb shell

— You will see ‘#’ that means you are in.
If it is not working you can have following problems:
a. You didn’t turned on USB device debugging (Find it in USB connection options in Settings);
b. You didn’t add the USB vendor id into the android rules file: http://developer.android.com/guide/developing/device.html

Otherwise, everything is okay and we can continue.

1. Install apk
If you are in the device shell (#), just type:

# exit

cd to the folder where is your apk is situated and type following command in the your Terminal:

~$ adb install my_cool_application.apk

— That’all :))

2. Uninstall application
Ordinary I’m doing that using following approach:
1. ~$ adb shell
2. # pm list packages
3. Find the package, I want to uninstal: com.mycpmpamy.myapplication
4. # pm uninstall com.mycpmpamy.myapplication
Done!

3. Navigating file system
You can use all ordinary commands: cd, pwd, ls etc. But you are not allowed to use TAB for auto completing the path or command AND you have to use ” before every system character, for example:

# cd media/my file&my life folder

4. To read any file content you can use simple command:

#cat myfile.txt

5. To copy file onto device you can use one more simple command:

~$ adb push my_cool_file.txt /media

— Where /media is partition or path, where you want your file to be copied

Note: also you can use adb logcat from terminal to have separate window with log, it is especially useful if you want to have a log with topmost window, but it should cover a not huge area on your screen. It is the most coolest feature in the Ubuntu, you can right click on any window’s title and click a tick ‘Always on top’ and window always will be on the foreground!

Also, you can run tests just from the console! And you do not need IDE for tests start, working and reporting results! I will describe it in the next articles.

Happy debugging (:

Best regards,
Yahor