【问题标题】:"adbd cannot run as root in production builds" even though the 'debug' build variant is selected?即使选择了“调试”构建变体,“adbd 无法在生产构建中以 root 身份运行”?
【发布时间】:2019-05-09 12:36:38
【问题描述】:

我正在尝试将 Android 模拟器指向本地 VM,为此我需要 adb root。但是,我收到了这个错误:

$ adb root
adbd cannot run as root in production builds

但我正在运行的p2p-app 的构建变体是debug

p2p-app 模块的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 变体具有debuggable true,我希望它可以获得对模拟器的root 访问权限?

【问题讨论】:

标签: android android-emulator adb root


【解决方案1】:

ADB root is not working on emulator 之后,我通过Google API 系统映像而不是Google Play 系统映像创建了一个模拟器,从而克服了这一限制(见下面的屏幕截图)。

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

$ adb root
restarting adbd as root

【讨论】:

    【解决方案2】:

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

    如果是 Android 模拟器配置,则无法授予 root 权限。此外,它是完全多余的,因为adbd 和模拟器的shell 与库存设备(a.k.a non-root)相比具有更高的权限。

    此外,可以在here 找到关于库存设备和模拟器之间差异的非常小的额外说明。

    【讨论】:

      猜你喜欢
      • 2019-05-08
      • 2014-10-05
      • 2019-08-31
      • 2017-10-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-16
      • 2021-04-20
      相关资源
      最近更新 更多