question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Undefined is not an object (evaluating 'ImagePickerManager.showImagePicker') on Android

See original GitHub issue

Description

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:closed
  • Created 6 years ago
  • Reactions:8
  • Comments:14 (1 by maintainers)

github_iconTop GitHub Comments

5reactions
thedanielforumcommented, Aug 8, 2018

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() to createAdditionalReactPackages().

Here is my complete working MainApplication.java file: gist: MainApplication.java

2reactions
dobiedadcommented, Aug 29, 2017

I just got this issue. It seems you need to rebuild after linking. Just call react-native run-ios/android after calling react-native-link

Read more comments on GitHub >

github_iconTop Results From Across the Web

react native - TypeError: undefined is not an object (evaluating ...
It works because we all found and copied code containing showImagePicker , but that method doesn't exist in version 3.x.x. So, we should...
Read more >
React-native – undefined is not an object(evaluating ...
But it is giving me undefined is not an object error. Also please tell me how can I link it to phone gallery...
Read more >
react-native-date-picker null is not an object - You.com | The search ...
Undefined is not an object (evaluating 'global.navigator.userAgent.match) in react native. Asked Dec 4, 2019 • 0 votes 1 answer. QUESTION ANSWERS.
Read more >
React Native Image Picker Example - C1CTech
Add the following lines to android/settings.gradle: ... undefined is not an object('evaluating 'ImagePickerManager.showImagePicker') ->I have this problem ...
Read more >
Typeerror: Undefined Is Not An Object (Evaluating ... - ADocLib
ios: null is not an object (evaluating 'ImagePickerManager. ... Cannot read property 'showImagePicker' of undefined on Android hot 28. open.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found