Android &引用;adbd不能在生产版本中以根用户身份运行;即使';调试';是否选择了构建变量?

Android &引用;adbd不能在生产版本中以根用户身份运行;即使';调试';是否选择了构建变量?,android,android-emulator,adb,root,Android,Android Emulator,Adb,Root,我试图将Android仿真器指向本地VM,为此我需要adb root。但是,我遇到了以下错误: $ adb root adbd cannot run as root in production builds 然而,我正在运行的p2p应用程序的构建变体是debug: p2p应用程序的build.gradle模块包括以下内容: android { buildTypes { release { minifyEnabled true

我试图将Android仿真器指向本地VM,为此我需要
adb root
。但是,我遇到了以下错误:

$ adb root
adbd cannot run as root in production builds
然而,我正在运行的
p2p应用程序的构建变体是
debug

p2p应用程序的
build.gradle
模块包括以下内容:

android {
    buildTypes {
        release {
            minifyEnabled true
            shrinkResources true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
            debuggable false
            signingConfig signingConfigs.release
        }

        debug {
            testCoverageEnabled = true
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
            debuggable true
            versionNameSuffix '-' + gitBranchName()
            applicationIdSuffix '.fifa'
            ext.betaDistributionReleaseNotesFilePath = "fabric-changelog.txt"
            ext.betaDistributionGroupAliases = "android-engineers"

        }
    }
}
由于
debug
变量具有
debugable true
,因此我希望能够获得对仿真器的root访问权限。

adb root
shell命令与任何应用程序的构建变量无关。该命令只是尝试在具有根权限的目标设备上重新启动
adbd
d
代表守护进程)。这是设备(仿真器)映像构建配置来授予这些映像的问题

对于Android emulator配置,无法授予根权限。此外,它是完全冗余的,因为与库存设备(又称非根设备)相比,
adbd
和emulator的
shell
具有更高的权限

此外,还可以找到关于库存设备和模拟器之间差异的一个非常小的额外解释。

接下来,我通过从谷歌API系统映像创建一个模拟器,而不是从谷歌Play映像创建一个模拟器,从而克服了这个限制(请参见下面的屏幕截图)

有了这个模拟器,我可以
adb root

$ adb root
restarting adbd as root