Alert dialog doesn't show on a built apk

I’ve tried importing the alert module from react native

import { Alert } from 'react-native'
Alert.alert( " Wish this worked :( " )

and expo.

import { Alert } from 'expo'
Alert.alert( " Or this ): " )

But neither will show the dialog on a built apk. Within the expo client the alerts will show for ios and android.

This error showed up, in sentry, when testing on a physical device

TypeError: undefined is not an object (evaluating 'u.Alert.alert')
  at ? ([native code])
1 Like

Same issue here

There are two way which works in both.

  1. import { Alert } from ‘react-native’;

    Alert.alert(
    ‘Title’,
    ’ Description’,
    [
    {
    text: ‘Yes’, onPress: () => { onPress: () => { console.log('Okay Pressed ok Alert ‘) } }
    },
    { text: ‘No’, onPress: () => { console.log(’ Pressed No Alert ') } },
    ],
    { cancelable: false }
    )

  2. alert(‘Description’)

Neither of those method signatures work on a built native binary, only when running the code in the expo client.

Environment Package.json ?

Is this what you are looking for

  "dependencies": {
    "@expo/vector-icons": "^6.2.2",
    "axios": "^0.17.1",
    "exp": "^47.1.1",
    "expo": "^28.0.0",
    "expo-analytics": "^1.0.7",
    "moment": "^2.20.1",
    "prop-types": "^15.6.0",
    "query-string": "^6.1.0",
    "react": "16.3.1",
    "react-native": "https://github.com/expo/react-native/archive/sdk-28.0.0.tar.gz",
    "react-native-communications": "^2.2.1",
    "react-native-keyboard-aware-scroll-view": "^0.5.0",
    "react-native-modal": "^5.0.0",
    "react-navigation": "^1.5.11",
    "react-redux": "^5.0.7",
    "redux": "^3.7.2",
    "sentry-expo": "^1.9.0",
    "validate.js": "^0.12.0"
  }

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.