1

im wondering how an android app might find out that it is running in an android emulator. Besides that, if the device is freashly booted, there are no user files and other applications installed. Are there any ressources on that topic?

Thanks in advance

lorem_stack
  • 111
  • 2
  • 11
  • One of SafetyNet Attestation API feature is to detect if app is running on emulator. But AFAIK there is no way to determine for sure if emulator is a cause of attestation rejection. – Gralls Mar 15 '20 at 15:29
  • refer this StackOverflow Post - it contains multiple ways of how app can detect if it is running on emulator - https://stackoverflow.com/questions/2799097/how-can-i-detect-when-an-android-application-is-running-in-the-emulator?noredirect=1&lq=1 – AADProgramming Mar 15 '20 at 15:35
  • 1
    Does this answer your question? [How can I detect when an Android application is running in the emulator?](https://stackoverflow.com/questions/2799097/how-can-i-detect-when-an-android-application-is-running-in-the-emulator) – a_local_nobody Mar 15 '20 at 15:36

1 Answers1

5

It is possible to get to know the details of the device your app is running on. From those details you can figure out, if the device is an Emulator or a physical device. Please go through the link below and see Fingerprint, Manufacturer, Device, Model, Product.

https://developer.android.com/reference/android/os/Build.html

For example: In your Splash Screen, if you put below code, then in your Logcat you should be seeing logs like below

`Log.e(TAG, "------------");
 Log.e(TAG, "Device Values");
 Log.e(TAG, "Fingerprint: " + Build.FINGERPRINT);
 Log.e(TAG, "Brand: " + Build.BRAND);
 Log.e(TAG, "Device: " + Build.DEVICE);
 Log.e(TAG, "Manufacturer: " + Build.MANUFACTURER);
 Log.e(TAG, "Model: " + Build.MODEL);
 Log.e(TAG, "Product: " + Build.PRODUCT);

 Real Device

 2020-03-15 20:46:07.136 32602-32602/com.utkarshnew.android E/NewSplashScreen:    ------------
 2020-03-15 20:46:07.136 32602-32602/com.utkarshnew.android E/NewSplashScreen:     Device Values
 2020-03-15 20:46:07.137 32602-32602/com.utkarshnew.android E/NewSplashScreen: Fingerprint: iBall/iBall_Slide_Cleo_S9/iBall_Slide_Cleo_S9:8.1.0/OPM2.1710/47218:user/release-keys
 2020-03-15 20:46:07.137 32602-32602/com.utkarshnew.android E/NewSplashScreen: Brand: iBall
 2020-03-15 20:46:07.137 32602-32602/com.utkarshnew.android E/NewSplashScreen: Device: iBall_Slide_Cleo_S9
 2020-03-15 20:46:07.137 32602-32602/com.utkarshnew.android E/NewSplashScreen: Manufacturer: iBall Slide
 2020-03-15 20:46:07.137 32602-32602/com.utkarshnew.android E/NewSplashScreen: Model: iBall Slide Cleo S9
 2020-03-15 20:46:07.137 32602-32602/com.utkarshnew.android E/NewSplashScreen: Product: iBall_Slide_Cleo_S9

 Emulator

 2020-03-15 20:53:44.725 6736-6736/com.utkarshnew.android E/NewSplashScreen: ------------
 2020-03-15 20:53:44.726 6736-6736/com.utkarshnew.android E/NewSplashScreen: Device Values
 2020-03-15 20:53:44.726 6736-6736/com.utkarshnew.android E/NewSplashScreen: Fingerprint: google/sdk_gphone_x86/generic_x86:10/QSR1.190920.001/5891938:user/release-keys
 2020-03-15 20:53:44.726 6736-6736/com.utkarshnew.android E/NewSplashScreen: Brand: google
 2020-03-15 20:53:44.726 6736-6736/com.utkarshnew.android E/NewSplashScreen: Device: generic_x86
 2020-03-15 20:53:44.726 6736-6736/com.utkarshnew.android E/NewSplashScreen: Manufacturer: Google
 2020-03-15 20:53:44.726 6736-6736/com.utkarshnew.android E/NewSplashScreen: Model: Android SDK built for x86
 2020-03-15 20:53:44.726 6736-6736/com.utkarshnew.android E/NewSplashScreen: Product: sdk_gphone_x86`

If you see the above logs, you'll see that for Emulator the Device value will come as Generic, whereas for a physical device, it'll show the name of the device model.

Also, please see these links

How can I detect when an Android application is running in the emulator?

How to check Android app is running in real device or virtual device?

sissyphus_69
  • 350
  • 5
  • 18
  • 1
    `Log.e` is for error logging, you should probably be using `Log.v` or `Log.i` – a_local_nobody Mar 15 '20 at 15:36
  • @a_local_nobody Correct. But you can also use it for it's color code(Red), makes particular log stand out in a plethora of logs, so can't miss it. – sissyphus_69 Mar 15 '20 at 15:39
  • it's a terrible idea to use it for that, considering that you can filter with logcat already. also, if you are using custom error logging in your app and forget one of these in your production app, you'll be logging errors on a production app, for no reason :) – a_local_nobody Mar 15 '20 at 15:40