camera.getPicture returns error 20

I’m building an Ionic 3 app for Android, and am using the camera plugin for choosing a pic from the camera or the photo gallery. It works fine when testing on Samsung Galaxy S4 running Android 5.1, and worked on the Android emulator as well as Nexus 6, but lately, instead of showing the gallery, it returns error message ‘20’ (no description, nada, just the number 20).
Here’s part of the code…

                quality : 75,
                destinationType : Camera.DestinationType.DATA_URL,
                sourceType : Camera.PictureSourceType.CAMERA,
                allowEdit : true,
                encodingType: Camera.EncodingType.JPEG,
                targetWidth: 300,
                targetHeight: 300,
                saveToPhotoAlbum: false
            }).then(imageData => {
                this.base64Image = "data:image/jpeg;base64," + imageData;
       = imageData;
       = this.base64Image;
            }, error => {
                console.log("ERROR -> " + JSON.stringify(error)); // This line shows ERROR -> 20

This only happens on the emulator and Nexus 6 - it works fine on the Galaxy S4.
Any ideas or suggestions? Thanks.

Finally solved it from this solution Camera, ImagePicker permission to access media. It had to do with permissions. For some odd reason, this line

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

vanished from AndroidManifest.xml

I added it back and the photo gallery now pops up.

None of the solutions work for me. I’m using ionic 3 with the latest Cordova and few different plugins that are accessing camera: barcode, camera, and gallery plugin. Barcode and gallery are working fine. They prompt properly for the permissions and accessing fine.
Camera throws error 20. I tested on a couple different Android phones( one had 6 and one had 8) and the behavior was the same.
I tried also using the diagnostic plugin mentioned above and ask for external storage authorization. I’m getting success back.
Any ideas?

Have you tried removing the camera plugin and adding it again?
Also, make sure that AndroidManifest.xml has both
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE">


<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE">

Good luck.

Actually, fixed it by implementing the solution from this thread: