Installed expo-image-picker, getting 'TypeError: undefined is not an object'

huangapple go评论53阅读模式
英文:

Installed expo-image-picker, getting 'TypeError: undefined is not an object'

问题

I'm here to assist with the translation. Here's the translated text:

(与 https://stackoverflow.com/questions/76296732/installed-react-native-image-picker-getting-typeerror-null-is-not-an-object?noredirect=1#comment134543272_76296732 一起发布,因为我不确定这两者是否有不同的根本原因。)

我正在尝试在我的 Expo RN 应用程序中使图像选择器正常工作。我的 package.json 包括以下内容:

    "expo": "~48.0.15",
    "expo-image-picker": "^14.1.1",
    "react": "18.2.0",
    "react-native": "0.71.8",

到目前为止,我对此的实现相对简单:

import * as ImagePicker from 'expo-image-picker';
...

const handleChoosePhoto = async () => {
    let result = await ImagePicker.launchImageLibraryAsync({
        mediaTypes: ImagePicker.MediaTypeOptions.All,
        allowsEditing: true,
        aspect: [4, 3],
        quality: 1,
    });
    console.log(result);
}

[稍后,有一个 TouchableOpacity,调用 handleChoosePhoto onPress]


这是根据 [Expo 的文档][1] 进行的。

当我尝试这个时,我收到了以下错误:

WARN Possible Unhandled Promise Rejection (id: 0):
TypeError: undefined is not an object (evaluating '_ExponentImagePicker.default.launchImageLibraryAsync')


我在 Expo 开发构建上尝试了这个。我尝试过更新 react-native(从 0.70.5 到现在的 0.71.8)和 expo(从 47 到 48)。我还在安装 react-native-image-picker 后执行了 npx pod-install。

我还刚刚修改了我的 `metro.config.js`,遵循了 [这个建议的解决方法][2],因为我遇到了 - 我认为与此无关 - 指向 `DatePickerIOS` 的错误。

有关出现问题的任何提示吗?

  [1]: https://docs.expo.dev/versions/latest/sdk/imagepicker/
  [2]: https://github.com/facebook/react-native/issues/36794#issuecomment-1500880284

Let me know if you need any further assistance!

英文:

(Posting this in conjunction with https://stackoverflow.com/questions/76296732/installed-react-native-image-picker-getting-typeerror-null-is-not-an-object?noredirect=1#comment134543272_76296732 because I'm not sure if these have different root causes or not.)

I'm trying to get an image picker working in my Expo RN app. My package.json includes these:

"expo": "~48.0.15",
"expo-image-picker": "^14.1.1",
"react": "18.2.0",
"react-native": "0.71.8",

My implementation of this so far is relatively simple:

import * as ImagePicker from 'expo-image-picker';
...

    const handleChoosePhoto = async () => {
        let result = await ImagePicker.launchImageLibraryAsync({
            mediaTypes: ImagePicker.MediaTypeOptions.All,
            allowsEditing: true,
            aspect: [4, 3],
            quality: 1,
        });
        console.log(result);
    }

[Later on, there's a TouchableOpacity that calls handleChoosePhoto onPress]

This is following Expo's documentation

When I try this out, I get the error:

 WARN  Possible Unhandled Promise Rejection (id: 0):
TypeError: undefined is not an object (evaluating '_ExponentImagePicker.default.launchImageLibraryAsync')

I'm trying this on an Expo development build. I've tried updating react-native (was on 0.70.5, now on 0.71.8) and expo (from 47 to 48). I've also done an npx pod-install after installing react-native-image-picker.

I also just modified my metro.config.js following this suggested workaround because I was getting the - I believe unrelated - error pointing to DatePickerIOS.

Any tips on what's wrong?

答案1

得分: 1

我有同样的问题,如果我记得正确,我只需要重新构建我的应用程序然后再次发布它。

英文:

I had the same issue and if I remember correctly all I had to do was rebuilding my app and publishing it again.

huangapple
  • 本文由 发表于 2023年5月21日 04:04:08
  • 转载请务必保留本文链接:https://go.coder-hub.com/76297134.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定