Using ADB with Android Emulators

Estimated reading: 3 minutes 110 views Contributors

Previously, we covered installing APK apps on your emulator. Now, let’s delve into using ADB (Android Debug Bridge) with Android emulators. ADB is a powerful command-line tool that enables communication with your emulator or device.

NOTE

Please ensure you have an emulator created and running before hand.

Devie Info: Pixel 8 | API 33

Connecting ADB to an Emulator

Once your emulator is running, you need to connect ADB to it.

1. Open Terminal: Launch the Terminal App on your on your Mac.

2. Navigate to ADB Directory: Navigate to the directory where ADB is installed. This is typically in the platform-tools directory of your Android SDK.

				
					cd /Users/<UserName>/Library/Android/sdk/platform-tools
				
			

3. Check Connected Devices: Run the following command to list connected devices and emulators.

				
					adb devices

				
			
You should see your emulator listed. If not, restart the ADB server. In Terminal paste the command below:
				
					adb kill-server
adb start-server

				
			

Common ADB Commands

Here are some essential ADB commands for quality testing:

  • Installing an APK: To Install an application on the emulator. Use this command.
				
					adb install /Users/</UserName>/Desktop/test-apps/app-debug.apk

				
			
  • Get Android Package Name: Get the name of the Android app’s package name in order to use the uninstall command later. With the test app lauched on the emulator, open a new terminal and enter this command below:
				
					adb shell dumpsys window | grep 'mCurrentFocus'
				
			
  • Uninstall an APK: Remove an application from the emulator.
				
					adb uninstall com.example.yourapp
				
			
adb-uninstall-app

Conclusion

The ADB is an essential tool for Android development and debugging. Mastering its commands will enhance your ability to manage and debug your applications effectively. Up next, we’ll cover automating UI tests on Android emulators, a crucial step for ensuring your app’s usability. Continue to Automating UI Tests on Android Emulators for detailed instructions.

Leave a Comment

Share this Doc

Using ADB with Android Emulators

Or copy link

    CONTENTS

    Keep Me Informed

    ×
    Cancel