How to Determine Android Device Screen Size and Density Using ADB

How to Determine Android Device Screen Size and Density Using ADB

22 April 2024 Stephan Petzl Leave a comment Tech-Help

When developing or testing Android applications, it’s often necessary to know the screen size and density of the device being used. Fortunately, Android’s ADB (Android Debug Bridge) provides commands that allow developers and testers to retrieve this information quickly and accurately.

Retrieving Screen Size and Density

To obtain the screen resolution and density of an Android device through ADB, you can use the following commands:

Screen Resolution

To get the physical size (screen resolution) of the device’s display, use:

        adb shell wm size

The output will be something like:

        Physical size: 2880x1600

Screen Density

To retrieve the physical density of the device’s display, use:

        adb shell wm density

Which will output something akin to:

        Physical density: 320

You can also override the screen density (for testing purposes) by specifying a new density value:

        adb shell wm density 160

Additional Methods

There are alternative methods to retrieve similar information using different subcommands within ADB:

  • dumpsys window displays: This command provides detailed information about the display, including the resolution and density.

                adb shell dumpsys window displays
  • dumpsys display: This command yields information about the default viewport and physical dimensions of the device screen.

                adb shell dumpsys display
  • dumpsys power: This command can show the width and height of the display among other power-related information.

                adb shell dumpsys power

Repeato: Streamlining Your Testing Process

Knowing the screen size and density is just one part of the mobile app testing process. With Repeato, you can take your testing to the next level. Repeato is a no-code test automation tool that supports testing on both iOS and Android platforms, regardless of the app framework used, such as React Native, Flutter, or Unity.

Its intuitive interface allows for quick editing and running of automated tests. Powered by computer vision and AI, Repeato is particularly adept at handling visual elements, making it an invaluable tool for ensuring your application’s UI is flawless across various screen sizes and densities.

Moreover, Repeato comes with ADB onboard, allowing you to execute ADB commands directly within the tool, streamlining your workflow and enhancing your testing capabilities.

Like this article? there’s more where that came from!