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

Crashed on Android with RN 0.34.1 #350

Closed
dangnelson opened this issue Oct 5, 2016 · 22 comments
Closed

Crashed on Android with RN 0.34.1 #350

dangnelson opened this issue Oct 5, 2016 · 22 comments

Comments

@dangnelson
Copy link

When running ImagePicker.showImagePicker the picker appears and allows me to make a selection, but the app crashes after I choose Library/Camera. It crashes before returning / logging anything.

@hasseio
Copy link

hasseio commented Oct 6, 2016

Downgrade to RN 0.32.1. I just tried most of the later versions, including 0.35.0-rc.0, and launchCamera() seems to crash hard on these later versions. 0.32.1 seems fine for me though.

@jamespearson
Copy link

I can confirm @hasseio 's finding.

It works on RN 0.32.1 but not on anything higher than that.

@dangnelson
Copy link
Author

Thanks for the help. With RN moving / changing so fast maybe listing which version a module was last confirmed to support should become a standard in developer documentation? Managing modules seems to be the biggest pain point right now. Great community might make up for it though.

@pthrasher
Copy link

I just dug in on this personally for my own project, and found the format for customButtons must have changed. Previously I had specified options.customButtons as just a simple hash:

options.customButtons = {
  'Upload Video': 'upload_video',
}

After changing it to the below it now works:

options.customButtons = [
  { title: 'Upload Video', name: 'upload_video' },
];

/cc @hasseio @fearmediocrity @dangnelson

@robmoorman
Copy link

Currently this package won't even compile, digging into it and providing a solution.

<...>/node_modules/react-native-image-picker/android/src/main/java/com/imagepicker/ImagePickerActivityEventListener.java:6: error: cannot find symbol
import com.facebook.react.bridge.BaseActivityEventListener;

@pthrasher
Copy link

pthrasher commented Oct 6, 2016

@robmoorman It compiles fine for me -- I'm using RN 0.34.1

I think you may have a separate issue. Probably best to open a new issue. This issue is about crashing at runtime.

@marcshilling
Copy link
Contributor

@robmoorman Try this. Make sure to run a gradle clean after the change.

@hasseio
Copy link

hasseio commented Oct 6, 2016

@pthrasher I'm not using custom buttons at all.

@lucassaldanha
Copy link

I'm using version 0.21.5 and after upgrading to react native 0.34 the app is crashing every time that I select the "Choose from Library..." option.

This is happening on Android and iOS.

@ianlenehan
Copy link

ianlenehan commented Oct 10, 2016

I'm having the same issue (crashes when picking Choose From Library option) but I've only tried it on iOS. I'm running RN v0.32.0. Happy to open a separate issue if it's not related to the same issue for Android.

@preterchan
Copy link

If this file has this line of code, you can try to comment.
android/app/src/main/java/[your package]/MainActivity.java
`

public void onActivityResult(int requestCode, int resultCode, Intent data){

    super.onActivityResult(requestCode, resultCode, data);

    //mReactInstanceManager.onActivityResult(this, requestCode, resultCode, data);

}

`
I just do it, it’s working

@dangnelson
Copy link
Author

If you're having iOS issues it's likely related to the new iOS 10 permissions requirements.
http://stackoverflow.com/questions/38498275/ios-10-changes-in-asking-permissions-of-camera-microphone-and-photo-library-c

I successfully used this to solve it on iOS:
https://github.com/yonahforst/react-native-permissions

@dangnelson
Copy link
Author

In my experience you have to both add the permissions to the info.plist and explicitly request them using a method like the component uses above or the app will crash in iOS.

@zccan
Copy link

zccan commented Oct 12, 2016

Need an available version ASAP, pls.

@ianlenehan
Copy link

Thanks @dangnelson got it working with your suggestions!

@marcshilling
Copy link
Contributor

@lucassaldanha why are you using verson 0.21.5? The latest is 0.22.9, try upgrading.

@marcshilling
Copy link
Contributor

@dangnelson are you still having issues on Android?

@dangnelson
Copy link
Author

I'm about to try again, will let you know.

@dangnelson
Copy link
Author

Just got it working on a fresh project with RN 0.35.0 & image-picker 0.22.9

Only issue I ran into was permissions weren't added to the AndroidManifest.xml file automatically by react-native link

@marcshilling
Copy link
Contributor

Glad to hear it. Since you were the original poster and it's now working, I'm going to close this issue since it's gone kind of all over the place. If anyone else is still having an issue, please open a new one with your specific problem.

@ospfranco
Copy link

Just leaving this here in case somebody has the same problem, I got an error:

java.lang.AbstractMethodError: abstract method "void com.facebook.react.bridge.ActivityEventListener.onActivityResult(android.app.Activity, int, int, android.content.Intent)"

if you get this problem, this is what worked for me:
Upgrade to rn 0.35
Upgrade image-picker to 0.22
cd android && ./gradlew clean

@BlooJeans
Copy link

to add to ospfranco's comment:
I had the same error, but his steps did not solve my problem.

I figured out that another RN package was doing reactContext.addActivityEventListener(this);, but the package was using an (old) ActivityEventListener, rather than a RN 0.35+ BaseActivityEventListener. The ImagePicker event listener was firing correctly, but RN would loop through all of the listeners, encounter the old listener and crash. The stack trace would just show the error that ospfranco posted, so it wasn't clear which package was causing the problem

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