Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TypeError: undefined is not an object (evaluating 'ImageResizerAndroid.createResizedImage')] #87

Closed
shuffgy opened this issue Jun 28, 2017 · 11 comments

Comments

@shuffgy
Copy link

shuffgy commented Jun 28, 2017

I checked the other issues but that did not help me.

I'm not quite sure what could be wrong in my Code, maybe because i'm using expo.io?

So, here is what i'm doing. (Some Snippets)

import { ImagePicker } from 'expo';
import ImageResizer from 'react-native-image-resizer';

    _pickImage = async () => {
        let result = await ImagePicker.launchImageLibraryAsync({
            allowsEditing: false,
            //aspect: [4, 3],
        });

        console.log(result);

        if (!result.cancelled) {
            //this.setState({ image: result.uri });
            ImageResizer.createResizedImage(result.uri, 800, 800, 100).then((resizedImageUri) => {
                // resizeImageUri is the URI of the new image that can now be displayed, uploaded...
                console.log("resizedImageUri: "+resizedImageUri);
            }).catch((err) => {
                // Oops, something went wrong. Check that the filename is correct and
                // inspect err to get more details.
                console.log("ERROR");
                console.log(err);
            });
        }
    }

What console says:

console.log(ImageResizer) shows

Object {
"createResizedImage": [Function createResizedImage],
}

console.log(result); (from the imagepicker)

Object {
"cancelled": false,
"height": 854,
"uri": "file:///data/user/0/host.exp.exponent/cache/ExperienceData/%2540shuffgy%252Fexpo-lunch-hkm/ImagePicker/7436892a-bf72-4334-a315-db81ce07a1d4.jpg",
"width": 1280,
}

console.log(err) makes my life hard with

[TypeError: undefined is not an object (evaluating 'ImageResizerAndroid.createResizedImage')]

Maybe you can help me... i'm using "react-native-image-resizer": "^0.1.1" in package.json. Tested on my Nexus 6P (Android)

@jamesbaker1
Copy link

Same thing is happening with me! Any luck?

@shuffgy
Copy link
Author

shuffgy commented Jul 12, 2017

@jamesbaker1 sadly no. Had no time for this in the past days, tried it now again, but I still have no idea why this is not working. What about you?

@jamesbaker1
Copy link

Seems like it was an issue with Expo not allowing you to add native code

@shuffgy
Copy link
Author

shuffgy commented Jul 12, 2017

So it is not possible at all or how did you managed it to make it work?

@4ian
Copy link
Contributor

4ian commented Jul 12, 2017

Expo.io do not allow to add modules with native code, so you have to "eject" from Expo to have a fully stand-alone React Native project before adding this module.
Another possibility is to ask Expo.io developers to add this module to their SDK.
Here is the Expo slack: https://slack.expo.io/
You can also ping them on Twitter: https://twitter.com/expo_io

@4ian
Copy link
Contributor

4ian commented Jul 12, 2017

We could add some kind of warning explaining that the module is not properly installed, or even detect that we're running inside of Expo to tell that the module is unsupported for now!

@jamesbaker1
Copy link

All great points, I can add a check for expo if you want. I ended up doing the image compression on the back end, though.

@chessbr
Copy link

chessbr commented Aug 24, 2017

I am facing this same issue with 1.0.0, no use of Expo though

EDIT: forget about it, I forgot to link.. 👍

@LA
Copy link

LA commented Sep 11, 2017

For future viewers, I got this issue as well because I forgot to restart iOS simulator after linking.

@PierreCapo
Copy link
Contributor

Closed as staled issue with old version of React-Native or react-native-image-resizer.

@Gareeeb7
Copy link

Try This
--import * as ImageResizer from 'react-native-image-resizer'

try {
    ImageResizer.default.createResizedImage(response.assets[0].uri, 100, 100, "JPEG", 100, 0)
    .then(res => {
      response.assets[0].name = response.name
      response.assets[0].size = response.size
       console.log('\n\n\nResponse = ',JSON.stringify(res));
    })
    .catch(err => {
      console.log("\n\n\nResizer-Error-->"+err) 
    });
  } catch (error) {
    console.log("\n\n\nResizer-Error-->"+error) 
  }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants