-
Notifications
You must be signed in to change notification settings - Fork 587
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
Using file-opener2 on Android 7, getting a 'Attempt to invoke virtual method' error #215
Comments
Exactly the same issue here. |
Did you recently make any changes to your project's config.xml file ? I faced similar issue recently. FileOpener2 was working fine for me but suddenly stopped working, giving this error "Attempt to invoke ....." . Then I realised that I had made some changes in project's config.xml file(In my case, I had disabled android backups ). That led to conflicts in "AndroidManifest.xml" on build. Due to which, "provider" tag inside AndroidManifest.xml disappeared causing the said error. To fix this, I copied code inside FileOpener2 plugin's xml file tag. Which was something like this :
and pasted it inside AndroidManifest.xml inside its tag. On building again, it started to work fine. |
@pralok I also had the same problem causing exactly by the same reason (disabling android backups). I think that manually updating AndroidManifest.xml is not the best solutions. I added a cordova hook executed on android platform add which changes the AndroidManifest.xml as required. Here is my solution:
Another option is to find all the plugins which make conflicting changes to AndroidManifest.xml and -readd the changes they make using edit-config in config.xml. However this could be not the best solutions as you might need to make this changes for the future pluging installs/updates. |
@ryaa You are correct. Manually updating AndroidManifest.xml is not the right way to go about it. I ended up removing and re-adding android platform. To disable backups, I used a cordova plugin(don't remeber which one) which works in a similar way to what you mentioned. |
@pralok I also tried this route and tried the below plugins with no luck |
@ryaa : I think I used this one. https://github.com/dpa99c/cordova-custom-config. Don't know if the conflict error you were having will go away or not. |
@pralok I used https://cordova.apache.org/docs/en/latest/plugin_ref/spec.html#edit-config to make the changes to AndroidManifest.xml. |
this worked for me. However i used edit-config in config.xml instead of modifying AndroidManifest.xml
|
hi @bengrah-miller, thanks for raising this issue. I believe this issue is now fixed in version |
Thank you very much @pralok and everybody else for this finding, never would have guess it! If anybody used the edit-config and still got problems to run the app, use the cordova-custom-config plugin as recomended by @pralok. After installing it, I just added the following line on my config.xml to solve the problem:
|
thanks everyone, I will update the README and then close this issue. |
I think the root cause of this is https://issues.apache.org/jira/browse/CB-13514, and that a bunch of other issues (such as #246, #259 and #268) might be caused by exactly the same reason. @shnist did you update the README – I cannot find any info about this in there? The bug still seems still to be present as of cordova-android 8.1.0 and I don't think |
Resolved by adding this in
Ionic CLI: 5.4.2 |
@nip3o there is a suggested fix by https://github.com/agm in #246. I've applied it and pushed it to master. Have a go at testing it against master and let me know if it resolves the issue. |
Hi there,
I know this issue has been brought up here before but I've not been able to get it resolved by using any of the detail provided. Here's my ionic info
I'm able to download a PDF, and we save it to the dataDirectory of the device:
this.fto.download(drawing.URL, this.file.dataDirectory + drawing.DrawingNo + ".pdf", true, this.getDrawingRequestHeaders).then((entry) => { console.log("### download complete: " + entry.toURL()) loading.dismiss(); obs.next(entry); obs.complete(); }, (error) => { console.log("### error: " + error) loading.dismiss() })
Which means we're going to save the file to this local URL:
"file:///data/user/0/com.company.companyapp/files/304-3B-4P-819.pdf"
When we open the drawing we're making the following call, the value of drawing.location is file:///data/user/0/com.company.companyapp/files/304-3B-4P-819.pdf
this.fileOpener.open(drawing.location, "application/pdf").then((success) => { console.log("### drawing opened"); }, (error) => { console.log("### error: " + error); })
Then we get the attached error. This only occurs on our Android 7 devices.
Can I get a steer on what I have to do to resolve this? I'd really appreciate it.
The text was updated successfully, but these errors were encountered: