Camera: Plugin_not_installed


#1

Hi all,

Whem I’m running my app trough ionic View app the camera works.
But when I’m running it from a debug package build from ionic pro I’m getting an error.

My code

startCamera(selectedSourceType:number)
    {

        let iQuality = parseInt(this.localstorage.getStorage('quality'));
        let bSaveSet = (this.localstorage.getStorage('save-photos') == 'true');

        const options: CameraOptions = {
            sourceType: selectedSourceType,
            quality: iQuality,
            destinationType: this.camera.DestinationType.DATA_URL,
            correctOrientation: true,
            encodingType: this.camera.EncodingType.JPEG,
            mediaType: this.camera.MediaType.PICTURE,
            targetWidth: 1024,
            targetHeight: 1024,
            saveToPhotoAlbum: bSaveSet
        }

        if(this.platform.is('android'))
        {
            this.platform.ready().then(() =>
            {
                this.camera.getPicture(options).then((imageData) => {

                    // Object picture
                    this.oObject['picture'] = 'data:image/jpg;base64,' + imageData;
                    if(this.oObject['picture'] !== '')
                    {
                        this.forwardToElements();
                    }


                    // Replace button
                    this.replaceBtn();

                }, (err) => {

                    // Handle error
                    alert(err);

                });
            });
        }
    }

Im landing in this section:

}, (err) => {

     // Handle error
     alert(err);

});

The content on the alert is:
plugin_not_installed

But yes, in my package.json I’ve the plugin installed.

"@ionic-native/camera": "^3.12.1",
"cordova-plugin-camera": "^2.4.1",

Im wondering why it’s working in Ionic view app and not working in the debug .APK

Hope that some one can help me!


#2

Does some one know’s a solution for this?


#3

have you effectively installed the plugin?


#4

Yes as I said in my start post I’ve installed the camera plugin.
It’s inside my package.json and the cordova plugin works in Ioniv View apps.

But it’s not working when I create a debug.apk


#5

weird, maybe an option which would be missing or didn’t work?

in case of, here are mine, could config works on android and ios

    let popoverOptions: CameraPopoverOptions = {
        x: 0,
        y: 0,
        width: 1080,
        height: 1080,
        arrowDir: this.camera.PopoverArrowDirection.ARROW_ANY
    };

    let options: CameraOptions = {
        quality: 90,
        destinationType: this.camera.DestinationType.FILE_URI,
        sourceType: sourceType,
        allowEdit: false,
        encodingType: this.camera.EncodingType.JPEG,
        targetWidth: 1080,
        targetHeight: 1080,
        mediaType: this.camera.MediaType.PICTURE,
        correctOrientation: true,
        saveToPhotoAlbum: false,
        cameraDirection: this.camera.Direction.BACK,
        popoverOptions: popoverOptions
    };

Note I used FILE_URI not DATA_URL but well I don’t think that’s the reason why the plugin isn’t found…


#6

I’m using DATA_URL because that is returning a base64-encoded string.
I’m using that because my application has to work offline so I’m storing the base64 in a SQLite table.


#7

Yep, but I mean maybe one of the other option?


#8

Have you also already try to reinstall the plugin?

ionic cordova plugin remove cordova-plugin-camera --save
ionic cordova plugin add cordova-plugin-camera --save

#9

Yeah already tried.

Should not make a difference.


#10

well then for my part I’ve got not more ideas. options you says it’s ok, reinstall you says you did…you have all edit-config tags in your config.xml? I know it has nothing to do with android but with an iOS quirks, but when some weird stuffs happens, who knows https://github.com/apache/cordova-plugin-camera


#11

and have you try to delete your app on your phone first before installing the new apk? well again make no sense, but who knows


#12

Yes, before installing the new .APK I delete the old app.

Yes in my config.xml is the reference for the camera plugin with the same version as in my package.json.

<plugin name="cordova-plugin-camera" spec="^2.4.1" />

#13

maybe try a newer version of the plugin? actual version is 3.0.0 … don’t know which cordovan-android you are using and if compatible…just check before

 <plugin name="cordova-plugin-camera" spec="^3.0.0" />
 <edit-config target="NSCameraUsageDescription" file="*-Info.plist" mode="merge">
    <string>need camera access to take pictures</string>
</edit-config>
<edit-config target="NSPhotoLibraryUsageDescription" file="*-Info.plist" mode="merge">
    <string>need to photo library access to get pictures from there</string>
</edit-config>
<edit-config target="NSLocationWhenInUseUsageDescription" file="*-Info.plist" mode="merge">
    <string>need location access to find things nearby</string>
</edit-config>
<edit-config target="NSPhotoLibraryAddUsageDescription" file="*-Info.plist" mode="merge">
     <string>need to photo library access to save pictures there</string>
</edit-config>

#14

I would try.
Going to update everything now.


#15

finger crossed, good luck

maybe in the meantime someone would be cleverer than me and bring a better idea…


#16

I think it will work. Tried so much else. I will keep you in touch!
Thanks for helping and giving me a fresh sight on this problem.


#17

Hi @reedrichards,

Fixed this issue by updating it to the version you mentioned.
Thanks for your help, appreciate it.

I will mark your answer as solution.


#18

Awesome, good to hear you solved it!