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

Plugin compile Android Error (Ionic Capacitor) #274

Open
lmsantanam opened this issue Mar 22, 2021 · 4 comments
Open

Plugin compile Android Error (Ionic Capacitor) #274

lmsantanam opened this issue Mar 22, 2021 · 4 comments

Comments

@lmsantanam
Copy link

After setting up this cordova plugin with an Ionic capacitor app, even thought is referenced in the official documentation how to be installed for capacitor:

https://ionicframework.com/docs/native/printer#installation

When I'm going to compile for Android, the plugin is throwing a lot of errors:
error

So maybe this plugin is deprecated? I don't have experience with fixing plugin's internal references, so if anyone has an idea would be great

@lmsantanam
Copy link
Author

Turns out the problem is with old android support dependencies (instead of using the new AndroidX equivalent). There is a workaround:

https://capacitorjs.com/docs/android/troubleshooting#error-package-androidsupport-does-not-exist

  1. npm install jetifier
  2. npx jetify
  3. npx cap sync android

But beware, if you install any new cordova plugin for a capacitor app you need to run steps 2 and 3 again. No idea if this happens with ionic cordova, or what is the procedure when a new repo is cloned and npm i is executed for the first time

I do think that this issue shouldn't be closed and be addresed sometime. For example in the plugin for file opener this issue has been opened for a couple of years now:

pwlin/cordova-plugin-file-opener2#256

@noname181
Copy link

Hi bro, can you share your code use this plugin with Ionic capacitor, hope your help <3

@lmsantanam
Copy link
Author

Hi bro, can you share your code use this plugin with Ionic capacitor, hope your help <3

Hi, no problem, what I do is like this:

1- I use another plugin (https://github.com/stephanrauh/ngx-extended-pdf-viewer) to show the pdf file in a separate page
2- I add a button on top of the page to that call a service with the printing function
3- The service validates that I'm on native platform (android or ios)
4- Then with the url to the pdf the code to print is this:

image

I do a http get with the file, then convert the result to base64, download to localstorage (to cache folder and using the FileSystem capacitor plugin) and finally the printer that is declared like this:

import { Printer } from '@ionic-native/printer/ngx';

constructor(
private printer: Printer
) { }

Is kind of slow since it downloads, convert to base64 and then is triggers the print function, but I couldn't figure out another way to use this print plugin and since all my pdf are lightweight, I'm using it like that

@noname181
Copy link

Thanks for your help, bro. let me try it

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