Android adb command line tool

Source: Internet
Author: User

1. start and close the ADB Service (adb start-server and adb kill-server)
According to the author's test, the adb service may be available after the simulator runs for a period of time (this service can be found in the Windows Process, which is used to serve the simulator or a real machine connected through a USB cable) an exception occurs. In this case, you need to shut down and restart the adb service again. Of course, restarting Eclipse may solve the problem. But that is troublesome. To manually disable the adb service, use the following command.
Adb kill-server
After the adb service is disabled, run the following command to start the adb service.
Adb start-server
2. query the current simulator/device instance (adb devices)
It is sometimes necessary to start multiple simulator instances, or to start the simulator while connecting the real machine through the USB data cable. In this case, you need to use the following command to query the number of online simulators or VMS.
Adb devices
If multiple simulators or real machines are online when running the Android program, a selection dialog box is displayed. If you choose to run on a real machine, ADT will directly install the program on the mobile phone.
3. install, uninstall, and run the program (adb install, adb uninstall, and am)
To run the Android program in Eclipse, you must have the Android source code project. How can I install and run only the apk file (the Android Application release package, which is equivalent to the exe file in Windows? The answer is the adb command. To install an ebook.apk file, run the following command.
Adb install ebook.apk
Assume that the package in ebook.apk is net. blogjava. mobile. ebook. You can run the following command to uninstall this application.
Adb uninstall net. blogjava. mobile. ebook
The concept of package will be learned in the future. Now, you only need to know that the package is the unique identifier of the Android application. If the program already exists on the simulator or on a real machine before installing the program, run the preceding command to uninstall the application and then install it. Or use the following command to re-install.
Adb install-r ebook.apk
When you uninstall an application, you can add the-k command line parameter to keep the data and buffer directory, and only uninstall the application. The command is as follows.
Adb uninstall-k net. blogjava. mobile. ebook
If there are multiple simulators or real machine instances on the machine, you need to use the-s command line parameter to specify the specific simulator or real machine. For example, the following commands install, reinstall, and uninstall the application on the simulator and the real machine respectively.
Install ebook.apk on the emulator-5554simulator
Adb-s emulator-5554 install ebook.apk
Install ebook.apk on a real machine
Adb-s HT9BYL904399 install ebook.apk
Reinstall ebook.apk on the emulator-5554simulator
Adb-s emulator-5554 install-r ebook.apk
Reinstall ebook.apk on a real machine
Adb-s HT9BYL904399 install-r ebook.apk
Uninstall ebook.apk on the emulator-5554simulator (data and buffer directory are not retained)
Adb-s emulator-5554 uninstall net. blogjava. mobile. ebook
Unload ebook.apk (keep data and buffer directory) on a real machine www.2cto.com
Adb-s HT9BYL904399 uninstall-k net. blogjava. mobile. ebook
If you want to run an installed application on a simulator or a real machine, you can run the program directly by running the following command in addition to directly operating on the simulator or real machine.
Run ebook.apk on the emulator-5554simulator
Adb-s emulator-5554 shell am start-n net. blogjava. mobile. ebook/net. blogjava. mobile. ebook. Main
Run ebook.apk on a real machine
Adb-s HT9BYL904399 shell am start-n net. blogjava. mobile. ebook/net. blogjava. mobile. ebook. Main
Mainis the main Activity of ebook.apk. It is equivalent to the main form of a Windows application or the home page of a Web application. Am is a shell command. About the shell command in the subsequent part

 


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.