skip to Main Content

I want to detect the difference between an emulator and a real device. I use the device_info_plus package to determine whether the device is an emulator or a real device. It works well, but when I try to run my app and test it in Bluestacks, NoxPlayer, or LDPlayer, it doesn’t work. When I run it in those emulators, the result is that it detects the device as a real device. How can I solve this problem?

I am trying to run my app on emulators such as Bluestacks, NoxPlayer, and LDPlayer to test whether it is running on an emulator or a real device. However, the emulators are being detected as real devices. How can I fix this?

2

Answers


  1. Chosen as BEST ANSWER

    I have found a solution to the problem:

    • Add the get_radio_version_plugin: ^0.0.1-beta* plugin to your pubspec.yaml file.

    • Get the value of radioVersion and compare it to the following values:

      • 1.0.0.0
      • "" (empty string)
      • null
    • If radioVersion is equal to any of these values, then the device is an emulator. Otherwise, the device is a real device.

    Example Code :

    if(radioVersion == '1.0.0.0' || radioVersion == ''|| radioVersion == null){
      //Emulator
    } else {
      //Real Device
    }
    

    >> Image Result <<


  2. Try this:

    class HomeScreen extends StatefulWidget {
      const HomeScreen({super.key});
    
      @override
      State<HomeScreen> createState() => _HomeScreenState();
    }
    
    class _HomeScreenState extends State<HomeScreen> {
      @override
      Widget build(BuildContext context) {
        return Scaffold(
          body: SafeArea(
            child: ElevatedButton(
              onPressed: () async {
                log("isPhysicalDevice: ${await checkIsPhysicalDevice()}");
              },
              child: const Text("Check Is Physical Device"),
            ),
          ),
        );
      }
    
      Future<bool> checkIsPhysicalDevice() async {
        final AndroidDeviceInfo androidInfo = await DeviceInfoPlugin().androidInfo;
        final bool finalCondition = androidInfo.fingerprint.startsWith("generic") ||
            androidInfo.fingerprint.startsWith("unknown") ||
            androidInfo.model.contains("google_sdk") ||
            androidInfo.model.contains("Emulator") ||
            androidInfo.model.contains("Android SDK built for x86") ||
            androidInfo.manufacturer.contains("Genymotion") ||
            androidInfo.brand.startsWith("generic") ||
            androidInfo.device.startsWith("generic") ||
            androidInfo.product == "vbox86p" ||
            androidInfo.device == "vbox86" ||
            androidInfo.hardware == "vbox86" ||
            androidInfo.product == "google_sdk";
        return Future<bool>.value(finalCondition);
      }
    }
    

    I assure you that it is more accurate than androidInfo.isPhysicalDevice.

    OR

    Try this: safe_device

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search