Undefined is not an object (evaluating 'ImagePickerManager.showImagePicker') on Android
See original GitHub issueDescription
Hello I’m trying to use react native image picker but I get this error. I import that by require js and I have no problem with logging
console.log(ImagePicker.showImagePicker)
it would show:
function showImagePicker(options, callback) { if (typeof options === 'function') { callback = options; options = {}; } return ImagePickerManager.showImagePicker(babelHelpers.extends({}…
but when i call that as a function i get undefined is not an object.
note that i’m using wix react native navigation and my MainActivirt extends
splashActivity and as it have written in Readme ( If MainActivity is not instance of ReactActivity, you will need to implement OnImagePickerPermissionsCallback to MainActivity )
my MainActivity is like code below
How to repeat issue and example
import com.reactnativenavigation.controllers.SplashActivity;
import com.imagepicker.permissions.OnImagePickerPermissionsCallback;
import com.facebook.react.modules.core.PermissionListener;
public class MainActivity extends SplashActivity implements OnImagePickerPermissionsCallback {
private PermissionListener listener;
@Override
public void setPermissionListener(PermissionListener listener)
{
this.listener = listener;
}
@Override
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults)
{
if (listener != null)
{
listener.onRequestPermissionsResult(requestCode, permissions, grantResults);
}
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
}
}
Additional Information
- React Native version:0.44.0
- Platform: Android
- Development Operating System: Windows
Issue Analytics
- State:
- Created 6 years ago
- Reactions:8
- Comments:14 (1 by maintainers)
Top GitHub Comments
I was struggling with this problem as well, so here is what worked for me. I am using wix/react-native-navigation routing, so my MainApplication is not the default config, hence the normal config didn’t work.
Turns our I needed to add
new ImagePickerPackage()
tocreateAdditionalReactPackages()
.Here is my complete working MainApplication.java file: gist: MainApplication.java
I just got this issue. It seems you need to rebuild after linking. Just call
react-native run-ios/android
after callingreact-native-link