ivpusic / react-native-image-crop-picker

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

No callback in Android, possible expokit problem. #782

Open Elitebigboss90 opened 5 years ago

Elitebigboss90 commented 5 years ago

Hi, I am working on a project and using this library. It works on iOS version without a problem but on Android, I cannot have any callback from it.

async launchImagePicker(type: "library" | "camera" = "library") { let result=[]; console.log("type",type) switch (type) { case "library": await ImagePicker.openPicker({multiple:true}).then(images=>{console.log(images),result=images}).catch(e=>{console.log(e)}); break case "camera": await ImagePicker.openCamera({width: 300, height: 400, cropping: true}).then(image=>{console.log(images),result=image}).catch(e=>{console.log(e)}); break }

I am doing something like this. Since I can perfectly have all I need on iOS, so it won't be the js part problem.

So I begin to check if there any issue with installation in Android Studio. After check, i think we may need a callback handler in MainActivity because I am using expoKit and my MainActivity is not instance of ReactActivity.

this is my MainActivity,

public class MainActivity extends DetachActivity {

@Override public String publishedUrl() { return "exp://exp.host/@chipske/redwood"; }

@Override public String developmentUrl() { return DetachBuildConstants.DEVELOPMENT_URL; }

@Override public List sdkVersions() { return new ArrayList<>(Arrays.asList("27.0.0")); }

@Override public List reactPackages() { return ((MainApplication) getApplication()).getPackages(); }

@Override public boolean isDebug() { return BuildConfig.DEBUG; }

@Override public Bundle initialProps(Bundle expBundle) { // Add extra initialProps here return expBundle; } }

Can someone help me to confirm it's the issue?

blackxored commented 5 years ago

If you don't have the permission in the Android manifest I've found this library seems to fail silently (even if you do requestPermission from the JS side). Please confirm you've that setup per README instructions.

Elitebigboss90 commented 5 years ago

@blackxored Hi, thank you for your reply. I have double checked and I do have permission in manifest.

I will try to repo this in a clean project with expokit.

ghostknow commented 5 years ago

same issue here, the startActivityForResult has not result code I found out the problem, thanks.

AnimaWolf commented 5 years ago

@Elitebigboss90 Were you able to fix this?

partriv commented 5 years ago

@ghostknow how did you fix it? I am also having this problem, running expokit.

partriv commented 5 years ago

I was able to 'fix this' by completely removing expokit. I used react-native init to create a new project, then copied my package.json, app/ folder, and platform specific configurations over and it was working after that. You can't just eject to expokit; and unfortunately you can't create an expo project and then eject to react native, that wont work either. You need to react-native init from scratch.

Unfortunately ejecting expo and running expokit comes with its own share of incompatibility i guess.

nasseh101 commented 5 years ago

same issue here, the startActivityForResult has not result code I found out the problem, thanks.

How did you fix this?

ghostknow commented 5 years ago

same issue here, the startActivityForResult has not result code I found out the problem, thanks.

How did you fix this?

you can try this @Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); mReactInstanceManager.onActivityResult( this, requestCode, resultCode, data ); }