Document directory
Yesterday I wrote about how to initialize the environment configuration for Android development. Today I will continue to talk about several major Android development and debugging tools, mainly ADB fastboot and emulator. Android Developers who use eclipse for development may not need to use these commands at all. However, to learn about the system, the tool is undoubtedly an android surgical knife.
Android's NAND structure and root process inevitably involve Android's NAND in the flash, root, and development and Debugging Processes ?). The main familiar partitions include boot, system, userdata, and recovery.
The system and userdata partitions are mounted to the/System and/Data Directories In the android File System. These two directories can be seen when the debugging tool ADB is used./data allows reading and writing, it mainly stores user self-installed programs and user personal data generated by using devices. The system directory stores system files and pre-installed important system applications, mounting to a file system does not allow read/write (unless the device is root ). The boot partition stores the kernel and initrd of the operating system. The recovery partition contains a backup system, which is mainly used for device upgrade, backup, and maintenance. To put it simply, you need to enter the recovery mode for Rom flushing.
When the device is working normally (that is, when the device is not root), only the userdata and cache partitions can be read and written, while other partitions are generally in the read-only status. The purpose of this design is to protect the system and the important programs of the system from being maliciously altered to ensure system security. IMG is overwritten into another version (for example, clockworkmod recovery image), and the NAND protection mechanism on the rediscovery partition is damaged, so that the NAND partition is completely unprotected and the system can be freely updated. IMG and boot. IMG, at this time, it can be said that the device is root, or that the NAND is in the "Unlocked" status. Therefore, it is a dangerous move for Android smartphone users to manually update the root mobile phone device and use the mobile phone files downloaded from the Internet to update the NAND.
Fastboot is a tool used by the android SDK to read and write NAND. It is located in the directory of Android-SDK-Linux/platform-tools. The following describes how to use fastboot. 1. The mobile phone must first enter the fastboot/recovery mode, and some devices must ensure that the device is in
S-OFF(Security off) status. The following is an illustration of the Huawei c8500 device. A: First shut down B: Hold down the "volume reduction key" and hold down the red "hang up key" (please do not open the "volume reduction key "), hold down the "power key" and never open (please do not open and hold down the "volume reduction key" and the red "hanging key") C: Keep holding down for about five seconds (hold down the three keys at the same time ), the mobile phone is displayed on the Huawei logo screen (the main screen of the mobile phone does not continue to start, that is, it has been paused on the Huawei logo boot screen ), that is, the mobile phone enters fastboot mode. 2. The following commands refresh the main partition of the NAND and restart it.
-
fastboot flash userdata data.img
-
fastboot flash system system.img
-
fastboot flash boot boot.img
-
fastboot reboot
3. Write the recovery partition and restart it.
-
fastboot flash recovery /path/to/<recovery>.img
-
fastboot reboot
4. Erase partitions
-
fastboot erase boot
-
fastboot erase recovery
ADB usage
After the installation is complete, the most important tool in the daily development and debugging process is ADB (Android debug Bridge), which is located in the Android-SDK-Linux/platform-tools directory. Software such as the bean clip is an application based on the underlying mechanism of ADB (because such an application requires devices to work in the development and debugging mode like ADB, I believe Android officials do not want to encourage such an application ). ADB usage instructions: http://developer.android.com/guide/developing/tools/adb.html 1, using a USB connection to connect Ubuntu and smartphone devices, and turn on the debug mode on the device. Set-> application-> development-> USB debugging option to check. 2. ADB devices can view the status of the device, and ADB shell can connect to the device to see a Linux system, and LS can also see the file directory ~ /Android/SDK/Android-SDK-Linux/platform-tools $./ADB Devices
List of devices attached
0a3aabb70502a00adevice
~ /Android/SDK/Android-SDK-Linux/platform-tools $./ADB Shell
# Ls
Acct init SD-ext
Cache init. c8500.rc sdcard
Config init. Goldfish. RC sys
D init. RC System
Data MNT ueventd. Goldfish. RC
Default. Prop proc ueventd. Huawei. RC
Dev root ueventd. RC
ETC sbin vendor
3. upload and download the ADB pull file <remote> <local>
ADB push <local> <remote>
4. View logs ~ /Android/SDK/Android-SDK-Linux/platform-tools $./ADB shell # logcat activitymanager: I *: S
16:01:03 04-12. 255 1262 1272 I activitymanager: Start proc COM. tencent. mm for broadcast COM. tencent. mm /. booter. policyreceiver: pid = 25676 uid = 10188 gids = {1006,300 3, 1015}
04-12 16:01:03. 482 1262 1290 I activitymanager: displayed activity com. Android. Settings/. applicationsettings: 323 MS (total 323 MS)
...... 4. Run the command on the system and enter the ADB shell. You can see that the/system/bin command can be run. Here, sqlite3 is used as an example, obtain the user data of the application (the root machine is dangerous ).
$ ADB-s emulator-5554 Shell
# Sqlite3/data/COM. example. Google. RSS. rssexample/databases/rssitems. DB
SQLite version 3.3.12
Enter ". Help" for instructions
... Enter commands, then quit...
SQLite>. Exit
Emulator usage
General Android Developers of emulator may not understand this because after the omnipotent Eclipse IDE is configured, developers directly write the application and then run debugging on the IDE. This undoubtedly greatly reduces the technical barriers of developers. Emulator is located in the Android-SDK-Linux/tools directory, the relevant official documentation: http://developer.android.com/guide/developing/tools/emulator.html http://developer.android.com/guide/developing/devices/emulator.html. Emulator works very easily. It creates virtual hardware devices on the development machine and runs the system on the virtual hardware devices. If you use Eclipse IDE, a virtual hardware device will be automatically reminded when you run the program for the first time (graphical interface, click it directly ). You can also create a virtual hardware device by using the command line. For more information, see http://developer.android.com/guide/developing/devices/managing-avds-cmdline.html. Create a virtual hardware device in the command line :~ /Android/SDK/Android-SDK-Linux/tools $./Android create AVD-N my_android2.3-T 3
Auto-selecting single Abi armeabi
Android 2.3.3 is a basic Android platform.
Do you wish to create a custom hardware profile [No]
Created AVD 'my _ android2.3 'based on Android 2.3.3, arm (armeabi) processor,
With the following hardware config:
HW. LCD. density = 240
VM. heapsize = 24
HW. ramsize = 256
Run the simulator on the command line to view the running interface of the android simulated device running on the qemu VM :~ /Android/SDK/Android-SDK-Linux/tools $./emulator-AVD my_android2.3
Use a simulator to load non-system default debugging NAND files. After creating a virtual hardware device, use the parameters of emulator to specify a third-party NAND partition file. For example, the following command specifies various self-compiled files:
./Emulator-AVD my_emulator_avd-system ~ /Cyanogenmod/out/target/product/c8500/system. IMG-data ~ /Cyanogenmod/out/target/product/c8500/userdata. IMG-kernel ~ /Cyanogenmod/out/target/product/c8500/kernel-ramdisk ~ /Cyanogenmod/out/target/product/c8500/ramdisk. IMG-Debug all