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

Image picker issues on Android #627

Closed
divyakoshy opened this issue Sep 11, 2017 · 20 comments
Closed

Image picker issues on Android #627

divyakoshy opened this issue Sep 11, 2017 · 20 comments
Assignees
Labels

Comments

@divyakoshy
Copy link

ImagePicker.launchImageLibraryAsync() and ImagePicker.launchCameraAsync() do not seem to work on Android standalone apps. The permissions are requested correctly, but the async calls never return and the view for taking/picking photos never appears.
Permissions have been put into the app.json, and on iOS things are working correctly. Not sure what I am missing D:

@anp
Copy link
Contributor

anp commented Sep 16, 2017

Hi! Can you provide an example of your code where this is happening? Maybe using Snack? Thanks!

@kazurus
Copy link

kazurus commented Sep 18, 2017

Same problem (two samsung different model, one launch, one not)
https://snack.expo.io/HJ2aKjTcW
https://forums.expo.io/t/imagepicker-launchcameraasync-does-not-start-on-some-devices/3195

@terribleben
Copy link
Contributor

@aalices is this something you're familiar with? Not sure

@brickpop
Copy link

brickpop commented Sep 26, 2017

I'm having the same issue.

            let result = await ImagePicker.launchCameraAsync({
                allowsEditing: true,
                aspect: [3, 4],
                base64: true
            });

On Android, this code will work on the Expo app, but will fail in the compiled standalone APK.

The error I get is that the user rejected the permissions (but I accepted them). Printing a JSON.stringify(err) of the error yields:

{
   framesToPop: 1,
   code: "EUNSPECIFIED"
}

The same works fine on iPhone, though.

@aalices
Copy link
Contributor

aalices commented Sep 27, 2017

@divyakoshy @akazimir @ledfusion I tested this on Xiaomi 4a, Nexus 5 and Samsung Galaxy Tab S2 and everything's fine. What devices are you using ?

@brickpop
Copy link

brickpop commented Sep 27, 2017

Hi @aalices,
I'm using Huawei P8 lite (Android 7.0) and BQ Aquaris X5 (Stock Android 7.1.1)

The following catch block:

catch (err) {
    Alert.alert("ERROR", (err && err.message) + "\n" + JSON.stringify(err));
}

Shows:

Screenshot

Thank you

@kazurus
Copy link

kazurus commented Sep 27, 2017

@aalices, Xiaomi Redmi 4 Prime (android 6.0.1), but I have no error in try-catch, just nothing happens and promise awaits result, permission in console.log - Object {expires: "never", status: "granted"}

@brickpop
Copy link

Switching to the Expo's camera component, and the problem is gone:
https://docs.expo.io/versions/latest/sdk/camera.html

@divyakoshy
Copy link
Author

Apologies for the delay in responding. I was able to fix this issue by removing all Permissions for android in app.json.

@anp
Copy link
Contributor

anp commented Oct 11, 2017

@akazimir looks like the other reporters resolved this by using the Camera component or by changing their permissions in app.json. Can you double check that you haven't removed the necessary permissions in app.json?

Since the original report has been resolved, going to give this a close. If it's still an issue and we have a reproduction, I'll happily reopen. Thanks!

@anp anp closed this as completed Oct 11, 2017
@rintoj
Copy link

rintoj commented Nov 7, 2017

@dikaiosune, I still see the same issue. I have the following permissions in app.json. Am I missing something here?

{
   "android": {
      "permissions": [
        "CAMERA",
        "READ_INTERNAL_STORAGE",
        "READ_EXTERNAL_STORAGE",
        "WRITE_EXTERNAL_STORAGE"
      ]
    }
}

@aalices
Copy link
Contributor

aalices commented Nov 9, 2017

@rintoj a new type of permission that you will be able to use via Permissions module will be probably available along with SDK 23 and you'll have to use it before opening the picker.

@budiadiono
Copy link

I have same issue.

This one was working fine:

  /**
   * Get picture from camera
   */
  async _takePicture() {
    const result = await ImagePicker.launchCameraAsync()
    if (!result.cancelled) {
      await this._setImage(result.uri)
    }
  }

But NOT for this one:

  /**
   * Select picture from image library
   */
  async _selectPicture() {
    const result = await ImagePicker.launchImageLibraryAsync()
    if (!result.cancelled) {
      await this._setImage(result.uri)
    }
  }

Nothing happens after image get selected -- I don't see any exception been thrown. I've tested on Android only using Xiaomi Redmi 2 Prime -- not sure about IOS.

I've made dummy project to reproduce this issue here: https://github.com/budiadiono/react-native-expo-image-picker-demo.

Published here: https://expo.io/@budiadiono/image-picker-demo.

Previously I was also trying to play with permissions things as discussed above but it didn't helps.

Any clue?

@budiadiono
Copy link

I found out that this issue raising when I'm using Gallery or Explorer to browse and select the image. Having no problem with Photos and Drive.

img_20171214_080259

@aalices
Copy link
Contributor

aalices commented Dec 15, 2017

@budiadiono fix in on it's way. Thanks! This was not related to previous reports anyway.

@donedgardo
Copy link
Contributor

@aalices Any updates? running into the same issue.
Thanks.

@aalices
Copy link
Contributor

aalices commented Dec 22, 2017

@donedgardo it is not yet merged. Not sure if there will be a minor release or it will be fixed in next SDK, @terribleben ?

@donedgardo
Copy link
Contributor

@terribleben ?

@ArsenyYankovsky
Copy link

ArsenyYankovsky commented Feb 10, 2018

@aalices This still isn't fixed. Why was the issue closed?

@terribleben
Copy link
Contributor

Hello recent repliers!

We don't think recent comments are related to the original issue in this thread, "Image picker issues on Android", opened last September, since the author of the issue was able to resolve their problem without us changing anything.

We've made lots of changes to this code in the last five months. If you have a new bug to report with ImagePicker, please open a new thread and follow the issue template.

@expo expo locked as resolved and limited conversation to collaborators Feb 12, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests