問(wèn)題描述
我剛剛更新了模擬器 26.0.3,現(xiàn)在我無(wú)法為新創(chuàng)建的模擬器運(yùn)行 adb root
命令.
I have just updated emulator 26.0.3, now I cannot run adb root
command for new created emulator.
顯示的錯(cuò)誤如下:
adbd 無(wú)法在生產(chǎn)版本中以 root 身份運(yùn)行
我已經(jīng)殺死并重新啟動(dòng) adbd
比如:
I have killed and restart adbd
like:
adb kill-server
adb devices
沒(méi)有任何幫助,有什么想法嗎?
Nothing helps, any ideas?
我不確定有什么區(qū)別以及如何選擇不同的構(gòu)建,但是,如果在創(chuàng)建時(shí)啟用了以下設(shè)置,則它具有 root.
I am not sure what is the difference and how to select different build but, if following settings are enabled while creating, then it has root.
推薦答案
要啟用 root 訪問(wèn)權(quán)限: 選擇未標(biāo)記為Google Play"的模擬器系統(tǒng)映像.(標(biāo)簽文本和其他 UI 細(xì)節(jié)因 Android Studio 版本而異.)
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.)
例外情況:截至 2020 年 10 月 8 日,Release R Android TV"系統(tǒng)映像不會(huì)以 root 身份運(yùn)行.解決方法:改用 Release Q(API 級(jí)別 29)Android TV 系統(tǒng)映像.
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.
測(cè)試它:啟動(dòng)模擬器,然后運(yùn)行 ??adb root
.應(yīng)該說(shuō)
Test it: Launch the emulator, then run adb root
. It should say
以root身份重啟adbd
或
adbd 已經(jīng)以 root 身份運(yùn)行
不是
adbd 無(wú)法在生產(chǎn)版本中以 root 身份運(yùn)行
替代測(cè)試:運(yùn)行adb shell
,如果提示以$
結(jié)尾,運(yùn)行su
.它應(yīng)該顯示 #
提示符.
Alternate test: Run adb shell
, and if the prompt ends with $
, run su
. It should show a #
prompt.
步驟:安裝和使用可以以root身份運(yùn)行的模擬器鏡像:
Steps: To install and use an emulator image that can run as root:
- 在 Android Studio 中,使用菜單命令 Tools >AVD 管理器.
- 點(diǎn)擊 + 創(chuàng)建虛擬設(shè)備... 按鈕.
- 選擇虛擬硬件,然后點(diǎn)擊下一步.
- 選擇一個(gè)系統(tǒng)映像.
- 選擇任何不說(shuō)(Google Play)"的圖片在目標(biāo)"列中.
- 如果您依賴(lài) Google API(Google Sign In、Google Fit 等),請(qǐng)選擇標(biāo)有(Google API)"的圖片.
- 您可能需要從推薦"切換到分組到x86 圖像";或其他圖像"組找到一個(gè).
- 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.
- 提示:以 API 級(jí)別編號(hào)開(kāi)頭的 AVD 名稱(chēng),以便虛擬設(shè)備列表按 API 級(jí)別排序.
[信用屬于@Merk,但這應(yīng)該作為答案而不是評(píng)論發(fā)布.]
[Credit belongs to @Merk but this should be posted as an answer rather than a comment.]
這篇關(guān)于ADB root 無(wú)法在模擬器上運(yùn)行(無(wú)法在生產(chǎn)版本中以 root 身份運(yùn)行)的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!