KC Blog

【UseCase】How to detect if your Android app is running on an emulator?

2 min read
AndroidDev#Android#Kotlin

Introduction

Sometimes product managers will request

a feature to prevent the app

from running on emulators after release

Here I've collected various detection methods

to share

Detection Methods

1. Using Android Built-in Properties
This method uses Android's Build class to check various hardware and software properties:
2. Checking Specific Files
Some files only exist in emulator environments, we can check if these files exist:
3. Checking Phone Numbers
Emulators typically have specific phone network settings:
4. Combining Multiple Methods
Combining all the methods above

to determine if it's an emulator

But I don't think every emulator can be perfectly detected

If emulator developers know these detection techniques

they could theoretically create emulators that bypass these methods

Considerations

The above are just methods that may identify an emulator

In practice, you might encounter the following situations:

  1. These methods are not 100% reliable, as emulators can be designed to simulate real devices

  2. Some real devices might be falsely identified as emulators (if a manufacturer's device happens to be missing properties or characteristics you're checking)

  3. Consider a different approach:

you could specifically block emulators you've encountered

Conclusion

  • Combine multiple detection methods to improve accuracy

  • Regularly update detection logic to adapt to new emulators

This might need to be handled case by case

Since QA will help test

When issues arise

they can report them to you

so you can address the specific problems

  • Consider whether this method is necessary

to avoid affecting user experience due to false positives

  • While these techniques can provide useful information

they are not absolutely reliable

Before implementing any logic based on these detection results

please consider potential impacts and necessity.