We installed the Camera Plugin for Ionic and are facing this error:
Attempt to invoke virtual method 'android.content.res.XmlResourceParser android.content.pm.ProviderInfo.loadXmlMetaData(android.content.pm.PackageManager, java.lang.String)' on a null object reference
We have already tried all the solutions provided at the link How can we fix it? Our (original) Manifest is:
<?xml version='1.0' encoding='utf-8'?>
<manifest android:hardwareAccelerated="true" android:versionCode="1" android:versionName="0.0.1" package="io.ionic.starter" xmlns:android="http://schemas.android.com/apk/res/android">
<supports-screens android:anyDensity="true" android:largeScreens="true" android:normalScreens="true" android:resizeable="true" android:smallScreens="true" android:xlargeScreens="true" />
<uses-permission android:name="android.permission.INTERNET" />
<application android:hardwareAccelerated="true" android:icon="@mipmap/icon" android:label="@string/app_name" android:supportsRtl="true">
<activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale" android:label="@string/activity_name" android:launchMode="singleTop" android:name="MainActivity" android:theme="@android:style/Theme.DeviceDefault.NoActionBar" android:windowSoftInputMode="adjustResize">
<intent-filter android:label="@string/launcher_name">
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<provider android:authorities="${applicationId}.provider" android:exported="false" android:grantUriPermissions="true" android:name="org.apache.cordova.camera.FileProvider">
<meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/camera_provider_paths" />
</provider>
<service android:enabled="true" android:exported="false" android:name="com.google.android.gms.measurement.AppMeasurementService" />
<service android:name="org.apache.cordova.firebase.FirebasePluginMessagingService">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
<service android:name="org.apache.cordova.firebase.FirebasePluginInstanceIDService">
<intent-filter>
<action android:name="com.google.firebase.INSTANCE_ID_EVENT" />
</intent-filter>
</service>
<receiver android:name="org.apache.cordova.firebase.OnNotificationOpenReceiver" />
</application>
<uses-sdk android:minSdkVersion="19" android:targetSdkVersion="27" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
</manifest>
20/NOV: To explain further, we attached the Camera call in code. First function successfully opens Gallery with specified sourceType. Second function fails with source type CAMERA in error mentioned above. We are using the plugin QR Scanner in same project, there the camera opens and is functional.
openGallery () {
let cameraOptions = {
sourceType: this.Camera.PictureSourceType.PHOTOLIBRARY,
destinationType: this.Camera.DestinationType.DATA_URL,
quality: 100,
targetWidth: 1000,
targetHeight: 1000,
encodingType: this.Camera.EncodingType.JPEG,
correctOrientation: true
}
this.Camera.getPicture(cameraOptions)
.then(imageData => {
this.base64Image = 'data:image/jpeg;base64,' + imageData;
err => console.log(err);});
}
takePhoto() {
let cameraOptions = {
sourceType: this.Camera.PictureSourceType.CAMERA,
destinationType: this.Camera.DestinationType.FILE_URI,
quality: 100,
targetWidth: 1000,
targetHeight: 1000,
encodingType: this.Camera.EncodingType.JPEG,
correctOrientation: true,
}
this.Camera.getPicture(cameraOptions)
.then(file_uri => {
console.log(file_uri);
},
err => console.log(err));
}