expo: [expo-device] isDevice returns true when app is running in emulator

Summary

What I’m expecting is to detect what kind of device the app is running on and then open/close notification service based on this. In simulator, expo-device detects correctly and isDevice returns -> false, but in an android emulator it’s true. It should be false as well.

I’m running project Mac M1 chip, this can be another reason why I see this.

Here is another link about this problem but from the other way around. https://forums.expo.dev/t/expo-device-package-api-bug/56802

Screenshot 2022-02-02 at 14 41 27

Managed or bare workflow? If you have ios/ or android/ directories in your project, the answer is bare!

bare

What platform(s) does this occur on?

Android

SDK Version (managed workflow only)

No response

Environment

Expo CLI 5.0.3 environment info: System: OS: macOS 12.1 Shell: 5.8 - /bin/zsh Binaries: Node: 14.17.3 - /usr/local/bin/node Yarn: 1.22.17 - /usr/local/bin/yarn npm: 6.14.13 - /usr/local/bin/npm Managers: CocoaPods: 1.11.2 - /opt/homebrew/bin/pod SDKs: iOS SDK: Platforms: DriverKit 21.2, iOS 15.2, macOS 12.1, tvOS 15.2, watchOS 8.3 Android SDK: API Levels: 29, 30, 31, 32 Build Tools: 29.0.2, 30.0.2, 30.0.3, 32.0.0 System Images: android-31 | Google APIs ARM 64 v8a, android-31 | Google Play Intel x86 Atom_64, android-32 | Google APIs ARM 64 v8a Android NDK: 22.1.7171670 IDEs: Android Studio: 2020.3 AI-203.7717.56.2031.7935034 Xcode: 13.2.1/13C100 - /usr/bin/xcodebuild npmPackages: expo: ~43.0.2 => 43.0.4 react: 17.0.1 => 17.0.1 react-dom: 17.0.1 => 17.0.1 react-native: 0.64.3 => 0.64.3 react-native-web: 0.17.1 => 0.17.1 npmGlobalPackages: expo-cli: 5.0.3 Expo Workflow: bare

Reproducible demo

It works with snacks as normal.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 4
  • Comments: 26 (10 by maintainers)

Most upvoted comments

Could you share what your fingerprint looks like, to validate it will be detected correctly by the patch?

osBuildFingerprint: google/sdk_gphone64_arm64/emulator64_arm64:12/XX0X.000000.000/0000000:user/release-keys

Where XX0X.000000.000/0000000 is a random alpha numeric code.

As a workaround, I added this line, but I hope it won’t be necessary in the future

else if (isAndroid && Device.productName?.includes("emulator")) { Alert.alert("Must use physical device for Push Notifications");}

IMO, this looks like a good patch.

still getting this issue

@keith-kurak @kbrandwijk the issue is still present (2022 August).

console.log( { Device } )

Object {
  "Device": Object {
    "DeviceType": Object {
      "0": "UNKNOWN",
      "1": "PHONE",
      "2": "TABLET",
      "3": "DESKTOP",
      "4": "TV",
      "DESKTOP": 3,
      "PHONE": 1,
      "TABLET": 2,
      "TV": 4,
      "UNKNOWN": 0,
    },
    "brand": "google",
    "designName": "emu64a",
    "deviceName": "sdk_gphone64_arm64",
    "deviceYearClass": 2013,
    "getDeviceTypeAsync": [Function getDeviceTypeAsync],
    "getMaxMemoryAsync": [Function getMaxMemoryAsync],
    "getPlatformFeaturesAsync": [Function getPlatformFeaturesAsync],
    "getUptimeAsync": [Function getUptimeAsync],
    "hasPlatformFeatureAsync": [Function hasPlatformFeatureAsync],
    "isDevice": true,
    "isRootedExperimentalAsync": [Function isRootedExperimentalAsync],
    "isSideLoadingEnabledAsync": [Function isSideLoadingEnabledAsync],
    "manufacturer": "Google",
    "modelId": null,
    "modelName": "sdk_gphone64_arm64",
    "osBuildFingerprint": "google/sdk_gphone64_arm64/emu64a:13/TPB4.220624.004/8808248:user/release-keys",
    "osBuildId": "TPB4.220624.004",
    "osInternalBuildId": "TPB4.220624.004",
    "osName": "Android",
    "osVersion": "13",
    "platformApiLevel": 33,
    "productName": "emu64a",
    "supportedCpuArchitectures": Array [
      "arm64-v8a",
    ],
    "totalMemory": 2057662464,
  },
}
Android Running app on sdk_gphone64_arm64
❯ adb shell getprop ro.build.fingerprint
google/sdk_gphone64_arm64/emu64a:13/TPB4.220624.004/8808248:user/release-keys

no “emulator” in any names

As a workaround, I added this line, but I hope it won’t be necessary in the future

else if (isAndroid && Device.productName?.includes("emulator")) { Alert.alert("Must use physical device for Push Notifications");}

Hi @kbrandwijk, I run the command and the result is google/sdk_gphone64_arm64/emulator64_arm64:12/SE1A.211012.001/7818354:userdebug/dev-keys

Thank you, that confirms my suspicion. I have a fix in the works that I linked above to address this issue.