Some of our players started to play our Android game using an Android emulator (BlueStacks) on PC.
I would like to detect it to set a custom metadata field in the CrashReportHandler, to filter Cloud Diagnostics reports based on whether the game is running in an emulator.
Please add functionality to detect whether an Android Player is running in an emulator.
If there is functionality in Unity to get this information already, please let me know. I didn’t find any API for it yet.
I added a test that displays the information gathered from SystemInfo. Everything looks pretty device’ish to me, expect for perhaps GraphicsDeviceID and GraphicsDeviceVendorID, which are both 0. However, I’m not sure whether these are also 0 for other Android devices. Do you know if these can be 0 on real Android devices too?
EDIT/UPDATE: (some) real devices also report 0 for GraphicsDeviceID and GraphicsDeviceVendorID.
Here is the SystemInfo dump running in BlueStacks:
This feature would be really useful. I’m also receiving some crash reports really suspicious to be running on an emulator and I have no way to know if that’s the case.
Building for iOS in our case.
This might work. Haven’t tested it, but the equivalent code works in Java.
public static class DeviceSpy
{
private static readonly string[] s_BlueStacksDirSigs =
{
"/sdcard/windows/BstSharedFolder",
"/mnt/windows/BstSharedFolder",
};
public static bool IsRunningBlueStacks()
{
foreach (string dir in s_BlueStacksDirSigs)
if (System.IO.Directory.Exists(dir))
return true;
return false;
}
}
Note that I only know this works with BlueStacks 4 and 5. (I just have yet to test anything else.)
I have no idea if this works with the cloud version, however I’m pretty sure that unless you publish your game to the BlueStacks game center yourself, you shouldn’t need to worry about the cloud version running your game.
Also, the “windows” directory is still named as such even on the Mac version (I just verified).
Thank you for the reply. I can confirm it works in BlueStacks 5.5.
I also found that some (but probably not all) Unity Cloud Diagnostics reports have com.bluestacks.BstCommandProcessor as install_store in the Meta Data. I guess it’s set when you install the APK from file, instead over the store.