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

After taking a picture, I get an error 'cancelled' #225

Open
butaminas opened this issue Oct 3, 2019 · 11 comments
Open

After taking a picture, I get an error 'cancelled' #225

butaminas opened this issue Oct 3, 2019 · 11 comments

Comments

@butaminas
Copy link

Which platform(s) does your issue occur on?

  • Android
  • 10.0
  • emulator. Pixel 3a

I'm developing an app on nativescript-vue and using this particular package on a onShowFileChooser event by extending the WebChromeClient.

The idea is to make the camera to show when clicking a <input type='file' /> button on a webview.

First of all, I request user permissions on load like this:

mounted() {
            requestPermissions()
},

Then on the onShowFileChooser I do something like this:

onShowFileChooser: function (WebView, ValueCallback, FileChooserParams) {
                        camera.takePicture()
                            .then(function (imageAsset) {
                                console.log("Result is an image asset instance");
                                var image = new Image();
                                image.src = imageAsset;                               
                            }).catch(function (err) {
                            console.log("Error -> " + err.message);
                        });

Whenever I click the file input field in a webview the camera app appears and I can take a picture. After taking the picture and clicking the check mark to confirm, I get back to my app but in the console, I see:

'Error -> cancelled'

I've tried solution, mentioned here but this wasn't the case.

Why do I get this error?
Besides that, anyone has any idea how to actually return the image to the input field?

Thanks!

@project-bot project-bot bot added this to Inbox in Plugins Team Oct 3, 2019
@AtoianAvetik
Copy link

AtoianAvetik commented Oct 29, 2019

Have the same issue:

  • NS 6.1.1
  • Android
  • 10.0 (API 29)
  • emulator: Pixel 3

Also, when tried to select some image from gallery, get another error:
[ERROR] Asset '/storage/emulated/0/Download/image.jpg' cannot be found.

@butaminas
Copy link
Author

Have the same issue:

  • NS 6.1.1
  • Android
  • 10.0 (API 29)
  • emulator: Pixel 3

Still don't know the reason for this to happen but the only thing that worked for me was to downgrade to Android 8.0 (API 26) Pixel 2 and I've also selected CPU/ABI to be x86_64 instead of x86 (don't know if this had to do anything with it though).

@dengyy-cq
Copy link

in camera.android.js
addline:
nativeFile.getParentFile().mkdir();

image

@AtoianAvetik
Copy link

@dengyy-cq Thanks for reply, but your solution didn't help.

@DimitarTodorov
Copy link
Contributor

DimitarTodorov commented Nov 1, 2019

Hi @butaminas ,

Can you please share a sample project with the mentioned setup where we can reproduce and eventually investigate and solve the issue you are observing.

@uzarsalan
Copy link

Same issue

@Luonnotar
Copy link

Hey! I had the same problem, solve it with this solution :
Adding in the AndroidManifest.xml
<application
...
android:requestLegacyExternalStorage="true"
...

Found here

@raphaelnm
Copy link

Same issue here. Tried your solution @Luonnotar , but it does not build.

BUILD FAILED in 15s
Unable to apply changes on device: emulator-5554. Error is: Command ./gradlew failed with exit code 1.

@AdamAtri
Copy link

pull request for fix: #237

@jakubgondar
Copy link

This issue makes camera plugin unable to work under Android 10 (API 29+) because API 29 uses scoped storage. For making your application compatible with current version of plugin, you can do 2 things to fix this:

a) put targetSdkVersion 28 into App_Resources/Android/app.gradle :

android {
  defaultConfig {
    ...
    targetSdkVersion 28
    ...

or:

b) Add android:requestLegacyExternalStorage="true" to application element in App_Resources/Android/src/main/AndroidManifest.xml

see https://developer.android.com/training/data-storage/compatibility

@creative-gestalt
Copy link

creative-gestalt commented Apr 19, 2020

@Gondy Thank you, that fixed the issue for me.

For anyone lurking here, my emulator was functioning fine, but my physical device would give this error right after confirming the photo was OK:

Error: java.io.FileNotFoundException: /storage/emulated/0/DCIM/Camera/NSIMG_20200419_174631.jpg: open failed: ENOENT (No such file or directory)

adding the targetSdkVersion 28 to my app.gradle resolved this for my physical device.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Plugins Team
  
Inbox
Development

No branches or pull requests

10 participants