ivpusic / react-native-image-crop-picker

iOS/Android image picker with support for camera, video, configurable compression, multiple images and cropping
MIT License
6.09k stars 1.55k forks source link

Android select image then no callback #553

Open cantianshu opened 6 years ago

cantianshu commented 6 years ago

Version

Tell us which versions you are using:

Platform

Tell us to which platform this issue is related

Expected behaviour

do callback functions and params (path, widht, height ... )

Actual behaviour

Steps to reproduce

  1. openPicker or openCamera while no callback then

Attachments

// stacktrace or any other useful debug info

Love react-native-image-crop-picker? Please consider supporting our collective: 👉 https://opencollective.com/react-native-image-crop-picker/donate

ivpusic commented 6 years ago

can you provide stacktrace?

VincentRong commented 6 years ago

Same here. Android, RN is integrated in my app by ReactRootView.

After choose the photo and return nothing (where I have console.log something). It doesn't crash and logcat seems normal.

hardcodet commented 6 years ago

+1. Only have this when a photo is taken - the image picker seems to work fine. The promise simply never resolves or fails. RN 0.52 / latest picker from NPM.

Here's my code:

    try {
        const image = await ImagePicker.openCamera({cropping: false});
        alert("took photo");
    } catch(e) {
        alert(e);
    }
ivpusic commented 6 years ago

do you have some time to debug this?

hardcodet commented 6 years ago

i'm very new to RN - I'll gladly invest some time, but TBH I wouldn't know where to look since there's no obvious failure...

kilgarenone commented 6 years ago

Having the same issue: After selected an image from gallery, it brings me to the cropping screen where it only shows spinner without my image.

cantianshu commented 6 years ago

// don't use Alert see data is callback // use renderImage see callback data

renderImage=(image)=> { return }

//调用相机 cameraOnPress=()=>{ this.props.modalVisibleFn( false )

//打开相机
ImagePicker.openCamera({
  width: 300,
  height: 400,
  cropping: true,
}).then(resJson => {
 //  don't use Alert  see data is callback

  if (resJson && resJson.path ) {
       // use  renderImage  see callback data 
        this.renderImage(  resJson.path )
  }
}).catch(e => {
   Alert.alert(e.message ? e.message : e);
 });

}

liuflwy@163.com

From: Kheoh Yee Wei Date: 2018-01-11 16:59 To: ivpusic/react-native-image-crop-picker CC: fulong; Author Subject: Re: [ivpusic/react-native-image-crop-picker] Android select image then no callback (#553) Having the same issue: After selected an image from gallery, it brings me to the cropping screen where it only shows spinner without my image. — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

hardcodet commented 6 years ago

@cantianshu Can you elaborate what you mean by see data is callback? I guess if the then function executes, an alert will show, no?

cantianshu commented 6 years ago

Remove 'alert 、Alert' it will interrupt the process

use :

renderImage=(image)=> { return }

liuflwy@163.com

From: Philipp Sumi Date: 2018-01-13 17:13 To: ivpusic/react-native-image-crop-picker CC: fulong; Mention Subject: Re: [ivpusic/react-native-image-crop-picker] Android select image then no callback (#553) @cantianshu Can you elaborate what you mean by see data is callback? I guess if the then function executes, an alert will show, no? — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

aMarCruz commented 6 years ago

@cantianshu , perhaps if you use...

  renderImage=(image)=> {
    return <Image style={styles.icon}  source={{ uri: image }} />
  }

works?

LyhengTep commented 6 years ago

untitled

Having the same issue pls help

aMarCruz commented 6 years ago

Same issue here, no errors but the activity indicator remains forever.

RN 0.52.0 Sansumg S7 Edge (Android 7.0) android.buildToolsVersion "25.0.3"

aMarCruz commented 6 years ago

@LyhengTep , please try removing width and height from the options, leave only cropping: true. This works for me ...but I'm getting 200px images :(

LyhengTep commented 6 years ago

@aMarCruz it remained the same bro :(

kilgarenone commented 6 years ago

Hey guys, i think there wasn't anything wrong with this library. You might wanna rebuild your apk, npm start, close and open your app and build the index.js again..that kind of stuffs..if still doesn't work, rm -rf node_modules && yarn. That worked for me anyway.

quy1403 commented 6 years ago

it seeem to be Image was damaged!!

aMarCruz commented 6 years ago

@LyhengTep you're right, same issue.

LyhengTep commented 6 years ago

@kilgarenone I've done like what you said bro but nothing change

LyhengTep commented 6 years ago

@quy1403 I dont know bro but every time it happened. I have to rebuild the application

quy1403 commented 6 years ago

Lets take a new photo and pick it!!!! It worked for me!

jswxwxf commented 6 years ago

Same issue here. On Samsung Note4 Android 6.0.1

ouabing commented 6 years ago

Same issue, but it's strange when I turn on remote debugging, it just works again... On Nexus 6P.

sfratini commented 6 years ago

Alright so I am doing some debuggng and I found the issue:

error01

Method threw 'com.facebook.react.bridge.ObjectAlreadyConsumedException' exception. Cannot evaluate com.facebook.react.bridge.WritableNativeMap.toString()

Now I am trying to see how to fix it.

sfratini commented 6 years ago

According to RN source code, either using putArray or putMap consumes the Map, so the exception is thrown. Weird thing is that the only place in the code where this is used is with compression or cropping. And I have disabled both and the issue still persists. I believe this could be a RN issue when it sends the values over the bridge.

sfratini commented 6 years ago

@ivpusic Hi! Sorry to bother you, but do you know where this issue could e coming from? I was able to check that there is a class called Arguments that converts what you send over the bridge to a WritableNativeMap and that is where the exception is thrown but it does not make sense, because the map itself is not consumed.

nikojohnarellano commented 6 years ago

I'm having this issue as well. Selecting photos and clicking open does not trigger callback function.

zsaCHG commented 6 years ago

I resolve this problem by

mReactInstanceManager = ReactInstanceManager.builder() .setApplication(getApplication()) .setBundleAssetName("index.android.bundle") .setJSMainModulePath("index") .addPackage(new MainReactPackage()) .setUseDeveloperSupport(BuildConfig.DEBUG) .setInitialLifecycleState(LifecycleState.RESUMED) .build();

@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { if (mReactInstanceManager != null) { mReactInstanceManager.onActivityResult(this,requestCode,resultCode,data); } }

Elitebigboss90 commented 6 years ago

@zsaCHG Hi, could you please elaborate where should I add these lines?

zsaCHG commented 6 years ago

@Elitebigboss90 In the Activity which the react native page attach. This Activity implements DefaultHardwareBackBtnHandler or extends ReactActivity.

shohailahm commented 6 years ago

Changing the sdk version to 27 did the trick for me

keung7251 commented 5 years ago

same here!!