Tackling ‘Permission Denied’ Errors in Android ADB Shell

Tackling 'Permission Denied' Errors in Android ADB Shell

22 April 2024 Stephan Petzl Leave a comment Tech-Help

When working with Android’s ADB (Android Debug Bridge), encountering ‘Permission Denied’ errors can be a common but frustrating issue. This occurs when attempting to execute certain commands within the ADB shell that require elevated permissions. Understanding how to resolve these errors is crucial for effective Android development and debugging.

Understanding the Root Cause

The ‘Permission Denied’ error typically indicates that the ADB daemon does not have sufficient permissions to execute the desired command. This is particularly prevalent when trying to access the /data directory on Android devices, which is protected and requires root access.

Acquiring Root Access

To overcome permission restrictions, you may need to restart the ADB daemon with root privileges. This can be achieved by executing the following command:

        adb root

This command restarts the ADB daemon with root permissions, allowing for greater access to protected directories and files on your Android device.

Working Without Root Access

If rooting the device is not an option, there’s an alternative approach using the run-as command. This command allows you to execute operations as the user ID of an application, providing access to the application’s data without requiring full root access. Here’s an example:

        adb exec-out run-as com.yourcompany.app ls -R /data/data/com.yourcompany.app/

Replace com.yourcompany.app with the package name of the application you’re trying to access. The exec-out variant executes the command without starting a full shell session, which helps to avoid output mangling.

Checking for Root Status

When you enter the ADB shell by typing adb shell, a $ symbol indicates a non-root user, while a # symbol signifies root access. If you’re expecting to have root access but only see a $, try entering su to switch to superuser mode. If the device is properly rooted, the prompt should change to #.

Developer Settings

In some cases, you may need to enable root access for ADB within the developer settings of your Android device. Look for an option related to ADB root access and enable it to allow root commands to be run from the command line.

Using Android Studio Tools

For developers using Android Studio, newer versions include tools such as Device Explorer and App Inspection. These tools allow access to application data for debuggable apps, bypassing the need for command-line operations for data access.

Accessing ANR Traces

If you’re specifically looking to retrieve ANR (Application Not Responding) traces, Android provides a simple command that aggregates various logs and system information, including ANR traces:

        adb bugreport

Integrating with Repeato

For those involved in automated testing, encountering ‘Permission Denied’ errors can disrupt the testing workflow. Our product, Repeato, provides a no-code test automation tool for iOS and Android that can help streamline this process. With Repeato, you can create, run, and maintain automated tests efficiently using computer vision and AI, regardless of the app framework.

Repeato’s built-in ADB capabilities allow for seamless interaction with the device during testing, including the execution of ADB commands through script steps. Its user-friendly interface and fast test editing and execution make it an excellent choice for overcoming hurdles like ‘Permission Denied’ errors, ensuring your automated testing is as smooth and reliable as possible.


Resolving ‘Permission Denied’ errors in ADB involves understanding the root cause and applying the appropriate solution, whether it’s restarting ADB with root permissions or utilizing the run-as command for non-rooted devices. By leveraging tools like Repeato, developers and testers can further enhance their testing strategies and overcome common obstacles encountered in Android development and testing.

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