Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attempt to invoke virtual method -- Again #259

Closed
newuser44 opened this issue May 23, 2019 · 2 comments
Closed

Attempt to invoke virtual method -- Again #259

newuser44 opened this issue May 23, 2019 · 2 comments

Comments

@newuser44
Copy link

newuser44 commented May 23, 2019

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 newuser44 changed the title Error Opening Statement file: Attempt to invoke virtual method -- Again Attempt to invoke virtual method -- Again May 23, 2019
@newuser44
Copy link
Author

newuser44 commented May 28, 2019

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
Copy link
Collaborator

shnist commented Oct 16, 2019

@newuser44 closing this ticket as a duplicate of #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.

@shnist shnist closed this as completed Oct 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants