pwlin / cordova-plugin-file-opener2

A File Opener Plugin for Cordova
MIT License
314 stars 587 forks source link

Attempt to invoke virtual method -- Again #259

Closed newuser44 closed 4 years ago

newuser44 commented 5 years ago

Expected Behaviour

Be able to open a saved file

Actual Behaviour

fileOpener catch path is called with error Console log dump -- Error Opening Statement 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

Steps to Reproduce

?? Download a blob file. Save the file to the phone. Open the file using fileOpener.

Platform and Version (eg. Android 5.0 or iOS 9.2.1)

Test on a Samsung S7 with Android 8.0 on it.

Cordova CLI info

Node version: v6.16.0

Cordova version: 7.0.1

Ionic 3.19.1

On Android Cordova 6.4.

Plugin version

I was getting this problem. Saw the other thread that talked about this was fixed in 2.1 I was on 2.0.19 (our other apps this works fine with that version). I uninstalled and installed the plugin again. Now I'm on.

Removed Android and added it back. Same problem. #### Sample Code that illustrates the problem ?? ``` //Files was saved so open it. this.fileOpener.open(documentsDirectory + this.fileName, 'application/pdf') .then( response => { //File opened this.thinking.closeLoading(); }) .catch(error =>{ THIS IS WHAT GETS CALLED this.thinking.closeLoading(); console.log("Error Opening Statement file: " + error); }); }) ``` #### Logs taken while reproducing problem Not sure where to find logs.
newuser44 commented 5 years ago

I got it working. Not sure why.
For some reason in the AndroidManifest.xml this was missing.

    <provider android:authorities="${applicationId}.opener.provider" android:exported="false" android:grantUriPermissions="true" android:name="io.github.pwlin.cordova.plugins.fileopener2.FileProvider">
        <meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/opener_paths" />
    </provider>

All my other apps had it. It makes sense that I would need the "opener_paths" The only thing I'm notice off hand that is a little different with this app is:
<uses-sdk android:minSdkVersion="22" android:targetSdkVersion="27" />

My other apps are using <uses-sdk android:minSdkVersion="16" android:targetSdkVersion="26"/>

Would that cause this? I have uninstalled android and add it back. I removed the plugin and put my original one 2.0.19 back.

shnist commented 4 years ago

@newuser44 closing this ticket as a duplicate of https://github.com/pwlin/cordova-plugin-file-opener2/issues/215. It seems to be the same issue. The plugin makes changes to the Android manifest xml file and if your config.xml also attempts to make changes then there is a clash and this error occurs. Looking into a fix now.