App crashing on using media capture plugin's captureImage

#1

This is my ionic info…

cli packages: (/usr/lib/node_modules)

@ionic/cli-utils  : 1.19.2
ionic (Ionic CLI) : 3.20.0

global packages:

cordova (Cordova CLI) : 8.0.0 

local packages:

@ionic/app-scripts : 3.2.0
Cordova Platforms  : android 7.1.4
Ionic Framework    : ionic-angular 3.9.2

System:

Android SDK Tools : 26.1.1
Node              : v8.11.3
npm               : 6.3.0 
OS                : Linux 4.15

Environment Variables:

ANDROID_HOME : /home/niranjan/Android/Sdk

Misc:

backend : pro

Cordova plugin version…

cordova-plugin-media-capture : ^3.0.2


AndroidManifest.xml file permissions are…

<uses-sdk android:minSdkVersion=“19” android:targetSdkVersion=“27” />
<uses-permission android:name=“android.permission.ACCESS_COARSE_LOCATION” />
<uses-permission android:name=“android.permission.ACCESS_FINE_LOCATION” />
<uses-feature android:name=“android.hardware.location.gps” />
<uses-permission android:name=“android.permission.RECORD_AUDIO” />
<uses-permission android:name=“android.permission.RECORD_VIDEO” />
<uses-permission android:name=“android.permission.READ_EXTERNAL_STORAGE” />
<uses-permission android:name=“android.permission.BLUETOOTH” />
<uses-permission android:name=“android.permission.WRITE_EXTERNAL_STORAGE” />
<uses-permission android:name=“android.permission.CAMERA” />


github issues reference used


I am using media capture plugin to capture images and videos. Everything works fine in Android versions v5, v6, and v7. But the same application crashes in v8 and v8.1.

i have tested this application in android devices like vivo, samsung, motorola, redmi with versions above v8.0 but the same issue happens in every device.

please let me know if any possible solution available to this application crashing issue.

NOTE: captureVideo works fine in every device without any problem but only problem is with captureImage

Thanks in advance for your help…

#2

I solved my problem using diagonostic cordova plugin. Hope this might help someone

Just request run time permission using diagostic plugin and the application works fine for me without crashing.

//This line of code solved my problem this.diagnostic.requestRuntimePermission(‘WRITE_EXTERNAL_STORAGE’);

//reference https://ionicframework.com/docs/native/diagnostic/