expo: Unable to use Camera via ImagePicker through Expo Go on Android

Minimal reproducible example

https://github.com/chris-nolan/tunnel-app

Summary

ImagePicker should load the native camera UI and allow a picture to be taken. This works fine when doing a development build, however when running through Expo Go the following error occurs:

WARN Possible Unhandled Promise Rejection (id: 0): Error: Call to function 'ExponentImagePicker.launchCameraAsync' has been rejected. → Caused by: java.lang.NullPointerException: Parameter specified as non-null is null: method host.exp.exponent.experience.d.checkSelfPermission, parameter permission Error: Call to function 'ExponentImagePicker.launchCameraAsync' has been rejected. → Caused by: java.lang.NullPointerException: Parameter specified as non-null is null: method host.exp.exponent.experience.d.checkSelfPermission, parameter permission at construct (native) at apply (native) at _construct (http://192.168.68.81:19000/index.ts.bundle?platform=android&dev=true&hot=false:3251:28) at Wrapper (http://192.168.68.81:19000/index.ts.bundle?platform=android&dev=true&hot=false:3213:25) at construct (native) at _createSuperInternal (http://192.168.68.81:19000/index.ts.bundle?platform=android&dev=true&hot=false:112723:322) at call (native) at CodedError (http://192.168.68.81:19000/index.ts.bundle?platform=android&dev=true&hot=false:112731:26)

Environment

expo-env-info 1.0.5 environment info: System: OS: Windows 10 10.0.19044 Binaries: Node: 16.13.0 - ~\AppData\Local\Volta\tools\image\node\16.13.0\node.EXE Yarn: 1.22.17 - ~\AppData\Local\Volta\tools\image\yarn\1.22.17\bin\yarn.CMD npm: 8.1.4 - ~\AppData\Local\Volta\tools\image\npm\8.1.4\bin\npm.CMD npmPackages: @expo/webpack-config: ^18.0.1 => 18.0.1 expo: ~48.0.5 => 48.0.5 react: 18.2.0 => 18.2.0 react-dom: 18.2.0 => 18.2.0 react-native: 0.71.3 => 0.71.3 react-native-web: ~0.18.10 => 0.18.12 Expo Workflow: managed

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Reactions: 5
  • Comments: 59 (4 by maintainers)

Commits related to this issue

Most upvoted comments

I ended up going for Flutter no regrets.

Thanks! I confirmed that new Expo Go (2.29.1) Android version has no issues about this. 😄

It just happened during my react-native class, everyone with an Android 13 had the same problem. Paradoxically we had chosen expo for the compatibility between different hardware and operating systems 😃. We hope you can solve this problem 😄

Having the same issue as everybody else. launchImageLibraryAsync works fine but launchCameraAsync does not on my physical android device running ExpoGo

Thank you for filing this issue! This comment acknowledges we believe this may be a bug and there’s enough information to investigate it. However, we can’t promise any sort of timeline for resolution. We prioritize issues based on severity, breadth of impact, and alignment with our roadmap. If you’d like to help move it more quickly, you can continue to investigate it more deeply and/or you can open a pull request that fixes the cause.

What worked for me was following these steps:

  • downgrade expo (in my case from v48.0.5) to v47 with expo upgrade 47
  • remove all node_modules from the project and npm install them again
  • reinstall Expo Go by first uninstalling it manually from the emulator, then execute npm start to install Expo Go automatically

Many thanks to the team !

Testing with a Pixel 4 API 33 (Android 13). All seem to be working fine.

I just want to add some informations that will be useless after updating expo to version 49 (not possible yet):

If you uninstall expo go and relaunch the application, expo go will always be in version 2.28.8, the same if you install a new emulator

To update expo go on your emulator you will need to have the play store installed (emulators that have a play store icon on android studio). You need to go to playstore and update expo go.

Be careful when you have updated expo go to version 2.29.1 expo will tell you “Expo Go on xxxxx is outdated, would you like to upgrade?” (Y/n)

Enter “n” because it will downgrade expo go to version 2.28.8 otherwise

Unless someone knows an alternative way, that seems to me the easiest way to test before expo 49?

Hi @brentvatne, @gabrieldonadel (CC: @Kudo)

Sorry for pushing you about this, but I saw the upcoming SDK 49 beta release announcement in a week,

so I want to ask the followings.

  • Will the next Expo Go release include this fix in SDK 48 ?
  • Is there a chance for us (developers) to test next Expo Go Android apk before the next release ?

It is marked as fixed by https://github.com/expo/expo/pull/21912 but I’m still facing this issue =/

sooooo?

Hi @gabrieldonadel,

This fix did not seem to work for me. I reinstalled expo with npm and expo-image-picker with npm and still the same error. Am I supposed to do something else to correct this error now that it’s been patched?

The new version of Expo Go has not been released yet, in the meanwhile you can use dev client

I noticed that new Expo Go version (2.28.8 in GooglePlay) is released last week (4/25), but this issue is still happen and I guess that the cause is that the commit (https://github.com/expo/expo/commit/39684085747fe310d912b08767a3278ddd9e1dcd) doesn’t exist in sdk-48 branch’s commits history (https://github.com/expo/expo/commits/sdk-48).

This issue started to happen since SDK48 in Android Expo Go, so I hope that the fix will be included in next Expo Go release’s SDK48 module. 🙏

Any updates?

Hi @gabrieldonadel,

This fix did not seem to work for me. I reinstalled expo with npm and expo-image-picker with npm and still the same error. Am I supposed to do something else to correct this error now that it’s been patched?

The new version of Expo Go has not been released yet, in the meanwhile you can use dev client

I noticed that new Expo Go version (2.28.8 in GooglePlay) is released last week (4/25), but this issue is still happen and I guess that the cause is that the commit (3968408) doesn’t exist in sdk-48 branch’s commits history (https://github.com/expo/expo/commits/sdk-48).

This issue started to happen since SDK48 in Android Expo Go, so I hope that the fix will be included in next Expo Go release’s SDK48 module. 🙏

Do we have an idea of when the next release will take place ?

I have the same issue and I need to deploy my app ASAP without downgrading the version

Many thanks to the team !

Testing with a Pixel 4 API 33 (Android 13). All seem to be working fine.

I just want to add some informations that will be useless after updating expo to version 49 (not possible yet):

If you uninstall expo go and relaunch the application, expo go will always be in version 2.28.8, the same if you install a new emulator

To update expo go on your emulator you will need to have the play store installed (emulators that have a play store icon on android studio). You need to go to playstore and update expo go.

Be careful when you have updated expo go to version 2.29.1 expo will tell you “Expo Go on xxxxx is outdated, would you like to upgrade?” (Y/n)

Enter “n” because it will downgrade expo go to version 2.28.8 otherwise

Unless someone knows an alternative way, that seems to me the easiest way to test before expo 49?

Thanks this solution worked for me.

I’ve seen the commit of @brentvatne being merged into the sdk-48 branch and #21912 being closed. So I’ve updated to:

"expo": "^48.0.19"

But the Problem still persists. Is it the app that needs an update? If so, when are you going to release one?

I’m on Expo Go: 2.28.8 without the app store showing me an update.

Jesus Christ, I have updated expo sdk from 47 to 48 to fix an issue and now I have this issue.

Both ImagePicker.getCameraPermissionsAsync and ImagePicker.requestCameraPermissionsAsync return

{"canAskAgain": true, "expires": "never", "granted": true, "status": "granted"}

But when I call ImagePicker.launchCameraAsync, I get this:

Error: Call to function 'ExponentImagePicker.launchCameraAsync' has been rejected.
→ Caused by: java.lang.NullPointerException: Parameter specified as non-null is null: method host.exp.exponent.experience.d.checkSelfPermission, parameter permission

My libs:

{
   "expo": "^48.0.11",
   "expo-image-picker": "~14.1.1",
   "react-native": "0.71.6",
   "react": "18.2.0",
}

I don’t really know what to do right now, suggestions??

This fix did not seem to work for me. I reinstalled expo with npm and expo-image-picker with npm and still the same error. Am I supposed to do something else to correct this error now that it’s been patched?

The new version of Expo Go has not been released yet, in the meanwhile you can use dev client

@gabrieldonadel so Expo Go 2.28.4 on emulator is working as expected. A fresh install of Expo Go on my Pixel however, is still returning the same thing and failing. Very odd.

I’ve requested some additional devices from our IT department to test on - but its looking like this might be a device specific thing.

Expo go version is 2.28.4 on a Pixel 6, running Android 13, all up to date.

Will need to double check behaviour in emulator when back at work in the morning (UK time).

From the symptoms the problem is similar, so we open the camera and take a picture, then we click check. After the camera is closed, the app will restart. We found this only in some android 11 devices, it occurs in Oppo. There is no error in RN, but we found ANR_LOG code mention about memory issue in ADB LOG.

NOTE: sorry I replied using different account.

Sounds like a really different problem. The application did not close, there was simply an error message:

WARN Possible Unhandled Promise Rejection (id: 0): Error: Call to function ‘ExponentImagePicker.launchCameraAsync’ has been rejected. → Caused by: java.lang.NullPointerException: Parameter specified as non-null is null: method host.exp.exponent.experience.d.checkSelfPermission

Try with another device, or another emulator.

Or check with this working example :

config :
    "expo": "~48.0.18",
    "expo-image-picker": "~14.1.1",
    "react": "18.2.0",
    "react-native": "0.71.8",
    "expo-updates": "~0.16.4"
  import * as ImagePicker from "expo-image-picker";

  [photo, setPhoto] = useState(null);

  const onClick = async () => {
    const cameraPermission = await ImagePicker.requestCameraPermissionsAsync();
    if (cameraPermission.granted === false) {
      return;
    }

    const result = await ImagePicker.launchCameraAsync({
      mediaTypes: ImagePicker.MediaTypeOptions.Images,
      allowsEditing: false,
      aspect: [4, 3],
      quality: 1,
    });

    if (!result.cancelled) {
      const { assets } = result;
      if (assets && assets.length > 0) {
        setPhoto(assets[0].uri);
      }
    }
  };

we don’t use expo go and we have this issue also. so how do I solve this? Is it possible that upgrading to Expo 49 will resolve this issue?

The error was really locate in expo go 2.28.8 and for Android 13 see here I was mentioning expo 49 compared to the version of expo go that it would provide by default in the installation (currently expo 48 installs expo go 2.28.8 on device/emulator and expo 49 will install expo go 2.29.1). So expo 49 won’t fix anything more than expo go version. Are you sure the problem is not elsewhere?

It seems that this issue only occurs with devices that already have Expo Go installed. I tried to run the app in another device and it worked with no errors.

Expo Version: 48.0.19 Expo Go Version: 2.28.8

I am having the same issues as chris-nolan. Same error. No solutions listed have fixed my issues. Anyone have any other solutions?