USB debugging is a useful feature that allows developers to debug Android devices using ADB commands from a computer. ADB can help control a device and tweak system settings but it can communicate with your phone only if debugging via USB option is enabled in the Developer options. You must be desperate if you’re looking for a way to enable USB debugging and Developer options via commands. This article will seek answers if we can enable USB debugging using ADB commands, or if a USB debugging enabler tool is available for phones with a broken screen.
Having spent hours on Google searching for a miraculous workaround, I came across some people claiming to enable USB debugging using a command on their broken device.
Can we Enable USB Debugging Using ADB?
Well, the obvious answer is a “no” and here’s the explanation. We all know that ADB requires authorization from an Android device to communicate with it. The ADB daemon can access an Android device only after we allow USB debugging and validate the computer’s RSA key fingerprint. This is a security feature otherwise anyone who gets temporary possession of an Android phone can easily manipulate it.
It’s only in the Android Recovery Mode when the Apply update from ADB option is enabled that the ADB daemon can detect your device regardless of whether or not USB debugging is active in the device Settings.
However, if you try the ADB Shell commands, you’ll get the following error in return.
PS C:\> adb shell error: closed PS C:\>
If you have a rooted Android device and have TWRP recovery installed on it, there are better chances that you can successfully mount System and Data partitions using ADB. Please note that Fastboot doesn’t require USB debugging. You can boot your device into the Fastboot Mode and try
fastboot devices
fastboot oem unlock
The oem unlock
command can unlock your phone’s bootloader but in doing so, it’ll also perform a factory data reset.
Enabling USB Debugging via ADB
GitHub user Pantasio claims he could enable USB debugging via Recovery Mode using ADB commands. I am unsure if the allegedly working trick described by Pantasio will work for you, but it certainly didn’t work on my unlocked Galaxy S24 Ultra. I turned off the Developer options on my phone before following his steps. If you still want to give it a shot, follow the instructions.
Now, let’s come to the steps to enable USB debugging using ADB commands on devices with a broken or damaged screen. The method described below will work only on Android devices with an unlocked bootloader.
- Boot your Android device into the Recovery Mode.
- Download the latest SDK Platform-tools.zip and extract it.
- Open the ‘platform-tools‘ folder and launch a command window by clicking on File > Open Windows PowerShell in the folder window. If you have set up system-wide ADB and Fastboot, you can launch the command window from anywhere on your PC.
- Anyway, type the following command and press Enter.
adb devices
- If you get the device ID as an alphanumeric value in the command window, ADB has detected your device in the Recovery Mode. (Lucky you! :D) I could not get past this step.
- Now type
adb shell
and hit the Enter key. After that, execute themount data
andmount system
commands to mount the respective directories on your device.adb shell $ mount data $ mount system
- Now, you have to pull the persist.sys.usb.config file from your phone to the PC. To do that execute the following command. Don’t forget to replace the location where you want to save the pulled file with yours.
adb pull /data/property/persist.sys.usb.config C:\Users\Technastic\Desktop\
- Open the persist.sys.usb.config file with a text editor, edit it to “mtp,adb“, and save it. Now use the
adb push
command to send it back to your device.adb push "C:\Users\Technastic\Desktop/persist.sys.usb.config" /data/property
- It’s time now to download the build.prop file of your device to your PC.
adb pull /system/build.prop C:\Users\Technastic\Desktop\
- Open the build.prop file with a text and add the following lines to it.
persist.service.adb.enable=1 persist.service.debuggable=1 persist.sys.usb.config=mtp,adb
- Save the file and push it back to your phone.
adb push "C:\Users\Technastic\Desktop/build.prop" /system/
USB debugging should be enabled on your device. You can now reboot your phone to the system using the following command.
adb reboot
Your phone will boot up with USB debugging enabled but there’s a catch here! You’ll have to verify the RSA key fingerprint on your phone every time you use ADB commands.
Disabling USB Debugging via ADB
Well, enabling USB debugging on a device with a locked or broken screen might not be possible but you can easily disable it using an ADB command if it’s already enabled.
- Launch a command window with the path of the ADB.
- Connect your device to the computer and execute the following command after running
adb shell
.settings put global adb_enabled 0
- Now go to Settings > Developers options and you will find that USB debugging has been disabled.
Turning off Developer Options via ADB
Turning off the Developer options on a normal Android device is very easy. However, if you can’t navigate to the device settings and want to turn it off, do the following.
- Open a command window on your computer.
- Connect your device to the computer via a USB cable.
- Type
adb shell
, press the Enter key, and issue the following command to turn off the Developer options on your Android device.settings put global development_settings_enabled 0
- Hit the Enter key on your keyboard, to disable the Developer options.
To conclude, enabling USB debugging using ADB is impossible because the commands require USB debugging pre-enabled to interact with an Android device. Keeping USB debugging enabled on your Android phone could be a lifesaver in tricky situations.
Don’t Miss: How to Unlock PIN & Pattern on Android using ADB