ADB root is not working on emulator (cannot run as root in production builds)
To enable root access: Pick an emulator system image that is NOT labelled "Google Play". (The label text and other UI details vary by Android Studio version.)
Exception: As of 2020-10-08, the Release R "Android TV" system image will not run as root. Workaround: Use the Release Q (API level 29) Android TV system image instead.
Test it: Launch the emulator, then run adb root
. It should say
restarting adbd as root
or
adbd is already running as root
not
adbd cannot run as root in production builds
Alternate test: Run adb shell
, and if the prompt ends with $
, run su
. It should show a #
prompt.
Steps: To install and use an emulator image that can run as root:
- In Android Studio, use the menu command Tools > AVD Manager.
- Click the + Create Virtual Device... button.
- Select the virtual Hardware, and click Next.
- Select a System Image.
- Pick any image that does NOT say "(Google Play)" in the Target column.
- If you depend on Google APIs (Google Sign In, Google Fit, etc.), pick an image marked with "(Google APIs)".
- You might have to switch from the "Recommended" group to the "x86 Images" or "Other Images" group to find one.
- Click the Download button if needed.
- Finish creating your new AVD.
- Tip: Start the AVD Name with the API level number so the list of Virtual Devices will sort by API level.
- Launch your new AVD. (You can click the green "play" triangle in the AVD window.
[Credit belongs to @Merk but this should be posted as an answer rather than a comment.]
adbd cannot run as root in production builds even though the 'debug' build variant is selected?
The adb root
shell command has nothing to do with any app's build variant. The command just tries to restart adbd
(d
stands for daemon) on a target device with root permissions. And it is a matter of the device (emulator) images build configuration to grant those.
In case of Android emulator configuration the root permissions cannot be granted. Moreover, it is totally redundant as both adbd
and emulator's shell
have elevated privileges compared to stock devices (a.k.a non-root).
In addition a very small extra explanation on differences between stock devices and emulators can be found here.
adb root command returns adbd cannot run as root in production builds even on an emulator?
I checked some emulator provided by Google.
They are all user binary, not engineer binary.
You can check it yourself by using "adb shell" command.
If command line starts with "#", it's engineer build. If it starts with "$", it's user build. For example:
- jackpot2lte:/ # => engineer build
- jackpot2lte:/ $ => user build
Only engineer build can give you root permission. You can not change user build to engineer build but you can 'root' it.
Please check "How to get root access on Android emulator?" for more information.
Unable to run 'adb root' on a rooted Android phone
I finally found out how to do this! Basically you need to run adb shell
first and then while you're in the shell run su
, which will switch the shell to run as root!
$: adb shell
$: su
The one problem I still have is that sqlite3 is not installed so the command is not recognized.
Android: adb: Permission Denied
According to adb help
:
adb root - restarts the adbd daemon with root permissions
Which indeed resolved the issue for me.
Related Topics
Firebaserecycleradapter() Cannot Be Applied to Firebaserecycleradapter
How to Define Different Dependencies for Different Product Flavors
Using Global Exception Handling on Android
Why Is Android Geocoder Throwing a "Service Not Available" Exception
What's the Difference Between Fill_Parent and Wrap_Content
Continue Service Even If Application Is Cleared from Recent App
How to Make a Vertical Seekbar in Android
How to Use Accelerometer to Measure Distance for Android Application Development
Developing Cross Platform Mobile Application
Programmatically Update Widget from Activity/Service/Receiver
Google Signin Not Working in Release Mode APK Android
Alert Dialog from Android Service
What Is the Maximum Amount of Ram an App Can Use
How to Add a Line Break in an Android Textview
How to Open Email Program via Intents (But Only an Email Program)