@carolioli wrote:
I am trying to open a PDF file in my Ionic application and get the following error:
Error opening file 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
What the application does is that it receives a file in base64 format, transforms it to BLOB and then downloads it to the application directory, until this process all goes perfectly, this is the path it writes the file:
file:///data/user/0/io.ionic.starter/files/Informativo%202019_10_20%20e%2021
Then you run File Opener to open and the error pops:
this.file.writeFile(filePath, fileName, DataBlob, contentType).then((success) => { console.log("File Writed Successfully", success); //Method showing error below this.fileOpener.open(success.toURL(), this.contentType) .then(() => console.log('File is opened')) .catch(e => console.log('Error opening file', e)); }).catch((err) => { console.log("Error Occured While Writing File", err); });
I also have this file that I saw in other similar questions: opener_paths.xml
<?xml version="1.0" encoding="utf-8"?> <!-- https://developer.android.com/reference/android/support/v4/content/FileProvider.html#SpecifyFiles --> <paths xmlns:android="http://schemas.android.com/apk/res/android"> <!-- cordova.file.dataDirectory --> <files-path name="files" path="." /> <!-- cordova.file.cacheDirectory --> <cache-path name="cache" path="." /> <!-- cordova.file.externalDataDirectory --> <external-files-path name="external-files" path="." /> <!-- cordova.file.externalCacheDirectory --> <external-cache-path name="external-cache" path="." /> <!-- cordova.file.externalRootDirectory --> <external-path name="external" path="." /> </paths>
My AndroidManifest.xml:
<?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:networkSecurityConfig="@xml/network_security_config" 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> </application> <uses-sdk android:minSdkVersion="19" android:targetSdkVersion="26" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> </manifest>
Posts: 1
Participants: 1