Home > Tips and Tricks

ADB Shell Operation not allowed: java.lang.SecurityException [Fixed]

In this guide, we will show you the steps to fix the Operation not allowed: java.lang.SecurityException error while executing the ADB Shell command. The possibilities stand endless when it comes to stepping into the ADB and Fastboot domains. While Fastboot commands mostly come in handy when your device’s bootloader is unlocked or is rooted, that isn’t the case with ADB as you could extract the maximum potential of these commands in a stock environment as well.

Moreover, with the addition of adb shell commands, you could even carry out some administrative-level tasks on your non-rooted device. However, as of late, using these commands is proving to be a tough nut to crack. Numerous users have voiced their concern that whenever they execute an ADB shell command, they instead get greeted with the Operation not allowed: java.lang.SecurityException error.

ADB Shell Operation not allowed java.lang.SecurityException

What is interesting to note is the fact that the PC could identify the device in the ADB Mode, as upon executing the adb devices command, the CMD list out the serial number of the device. Moreover, even the adb shell command works well and good, as it will list out the device codename. However, any command that you execute after that will result in the aforementioned error. With that said, there does exist a couple of nifty workarounds that shall help you resolve this bug. So without further ado, let’s check them out.

Fix ADB Shell Operation not allowed: java.lang.SecurityException

ADB Shell Operation not allowed java.lang.SecurityException

Before starting with the fixes, we would recommend you checkmark the following prerequisites first [if not done already]:

The Prerequisites

  • Make sure that you are using the official Google ADB Binaires: Android SDK Platform Tools.ADB Shell Operation not allowed java.lang.SecurityException
  • Verify that the Command Prompt is opened inside the platform-tools folder.ADB Shell Operation not allowed java.lang.SecurityException
  • Developer Options and USB Debugging are enabled on your device.ADB Shell Operation not allowed java.lang.SecurityException
  • The adb devices command gives out the device serial ID. If that is not the case, then Revoke USB Authorization from Developer Options and try again.ADB Shell Operation not allowed java.lang.SecurityException
  • The adb shell command gives out your device codename. If that is not the case, then Revoke USB Authorization from Developer Options and try again.ADB Shell Operation not allowed java.lang.SecurityException

If your device qualify all these requirements, then proceed ahead with the below methods to fix the ADB Shell Operation not allowed: java.lang.SecurityException error.

Fix for Xiaomi Devices

  1. Head over to Settings > Additional Settings > Developer Options.
  2. Then enable the toggle next to the following three options:
    USB Debugging
    USB Debugging (Security Settings)
    Install via USB

    ADB Shell Operation not allowed java.lang.SecurityException

  3. Now retry executing the adb shell command, you will no longer get any errors.

Fix for OnePlus, Oppo, Realme

  1. Head over to Settings > System Settings > Developer Options
  2. Then disable USB Debugging. After that, enable the toggle next to “Disable Permission Monitoring”.ADB Shell Operation not allowed java.lang.SecurityException
  3. Now re-enable USB Debugging and execute the adb shell command, there should be no errors.

That’s it. These were the steps to fix the Operation not allowed: java.lang.SecurityException error while executing the ADB Shell command. If you have any queries concerning the aforementioned steps, do let us know in the comments. We will get back to you with a solution at the earliest.


Share: