I'm trying to point an Android emulator to a local VM, for which I need to adb root. However, I'm getting this error:
$ adb root
adbd cannot run as root in production builds
Yet the build variant I am running of the p2p-app is debug:
The build.gradle for the p2p-app module includes the following:
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"
}
}
}
Since the debug variant has debuggable true, I would expect it to be possible to get root access to the emulator?
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.