nativescript-camera icon indicating copy to clipboard operation
nativescript-camera copied to clipboard

Error: Uncaught (in promise): null

Open ghost opened this issue 7 years ago • 10 comments

I insert latest nativescript-camera plugin tns 3.2.1 typescript: 2.4.2 device htc 626

public takePicture() {
        if ( isAvailable() ){
            takePicture( { width: 300, height: 300, keepAspectRatio: false, saveToGallery: true } )
                .then(picture => {
                    console.dir(picture);
                    this.cameraImageSrc = picture;
                }).catch((err) => {
                //console.log("Error -> " + err.message);
            });
        }
    }
<Image row="1"
                           [src]="cameraImageSrc"
                           stretch="aspectFit"
                           margin="10"
                           width="200"
                           height="200"></Image>

I get this console: Error: Uncaught (in promise): null

ActivityManager: START u0 {act=android.media.action.IMAGE_CAPTURE flg=0x3 cmp=com.htc.camera/.CameraServiceEntry clip={text/uri-list U:content://hu.neosoft.praktiker.provider/external_files/DCIM/Camera/NSIMG_20171016_15427.jpg} (has extras)} from uid 10268 pid 28769 on display 0

Please help me what is wrong my code?

ghost avatar Oct 16 '17 13:10 ghost

Hi @bumbella, I tested the nativescript-camera plugin while using CameraTestAngular application on Android API level 19 and 23 and the plugin seems to work as expected. Regarding that could you give us some more info about the device and its API level. Also, you could try following the approach, which is used in the sample project and to verify, whether you will have the same problem.

export class AppComponent {
    public saveToGallery: boolean = true;
    public cameraImage: ImageAsset;

    onTakePictureTap(args) {
        takePicture({ width: 180, height: 180, keepAspectRatio: false, saveToGallery: this.saveToGallery })
        .then((imageAsset) => {
            let source = new ImageSource();
            source.fromAsset(imageAsset).then((source) => {
                console.log(`Size: ${source.width}x${source.height}`);
            })
            this.cameraImage = imageAsset;
        }, (error) => {
            console.log("Error: " + error)
        });
    }

tsonevn avatar Oct 17 '17 07:10 tsonevn

I'm just facing exactly the same issue

andriamanarivo avatar Apr 20 '18 12:04 andriamanarivo

I have the same problem on an HTC. This issue is urgent because I know of no workaround. @NickIliev Can you reopen the issue?

This was OK with nativescript-camera 3.0.0 but fails on version 4.0.2.

moritzvieli avatar May 19 '18 12:05 moritzvieli

@moritzvieli can you share a Playground project or a sample application /code snippet that can reproduce the issue - also please post detailed information about the used version of tns-core-modules, nativescript-camera and runtimes (the content of the project's package.json)

NickIliev avatar May 21 '18 06:05 NickIliev

I've faced the same issue and the source of the problème is that there was no folder named camera inside the DCIM folder where the plugins want to store the pictures. After creating the camera folder, the uncaught promise error doesn't no longer appear. Le 21 mai 2018 9:13 AM, "Nick Iliev" [email protected] a écrit :

@moritzvieli https://github.com/moritzvieli can you share a Playground project or a sample application /code snippet that can reproduce the issue

  • also please post detailed information about the used version of tns-core-modules, nativescript-camera and runtimes (the content of the project's package.json)

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/NativeScript/nativescript-camera/issues/60#issuecomment-390562800, or mute the thread https://github.com/notifications/unsubscribe-auth/AjI4Np8D53fgVsLkhXqWdOf2s46uUUOBks5t0lsGgaJpZM4P6msQ .

andriamanarivo avatar May 21 '18 06:05 andriamanarivo

@NickIliev I created a playground project and it's working fine there: https://play.nativescript.org/?template=play-ng&id=K9bfFz&v=3

I'm on it, figuring out the differences.

moritzvieli avatar May 21 '18 11:05 moritzvieli

I updated nativescript and the core modules to the latest version and now I'm getting these errors: JS: ERROR Error: Uncaught (in promise): Asset '/storage/emulated/0/DCIM/Camera/NSIMG_20180522_71532.jpg' cannot be found. JS: onFailure 63 java.lang.IllegalArgumentException: unknown image format

But it's still not working, compared to the playgrounds version. The code however is still not working with my local project. I'll investigate further...

moritzvieli avatar May 22 '18 05:05 moritzvieli

@NickIliev @andriamanarivo is right. as soon as I add the "Camera" folder, everything works fine. Meanwhile, I haven't figured out, why it works on the playgrounds but not on my local project. I tested it using the following setup:

tns --version 3.4.3

tns-core-modules 4.0.1

nativescript-camera 4.0.2

As stated above, It worked with a previous version of nativescript-camera. 3.2.1 is fine for example. I think, the saveToGallery-flag switched to true as default. Switching it to false is a workaround.

moritzvieli avatar May 22 '18 17:05 moritzvieli

Update: I was looking at the wrong place, it turns out we're using another plugin for picking images, which has this bug, which could be related. https://github.com/NativeScript/nativescript-imagepicker/issues/309

It also has a workaround, so please ignore my comment below :)


I just ran into this issue when trying to select an image from the library:

JS: ERROR Error: Uncaught (in promise): Asset '/storage/emulated/0/DCIM/Camera/NSIMG_20190514_192513.jpg' cannot be found.

tns info ✔ Getting NativeScript components versions information... ✔ Component nativescript has 6.3.3 version and is up to date. ✔ Component tns-core-modules has 6.3.2 version and is up to date. ✔ Component tns-android has 6.3.1 version and is up to date. ✔ Component tns-ios has 6.3.0 version and is up to date.

"nativescript-camera": "^4.5.0",

Tested on

  • real device Google Pixel 3, Android 10 -> Not OK
  • real device Samsung S9, Android 9 -> OK
  • emulator Pixel-ish, API 29, Android 10 -> Nok OK
  • emulator Nexus-ish, API 28, Android 9 -> OK

fpaaske avatar Jan 22 '20 14:01 fpaaske

@fpaaske did you fix it?

dudipsh avatar Apr 27 '21 05:04 dudipsh