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

java.lang.IllegalStateException #3

Closed
safapps opened this issue Mar 9, 2020 · 8 comments
Closed

java.lang.IllegalStateException #3

safapps opened this issue Mar 9, 2020 · 8 comments

Comments

@safapps
Copy link

safapps commented Mar 9, 2020

This error is happening in some Androids, it happened to me on Android 8 and Android 10:

The error line follows:

at com.pdf.generator.OffscreenBrowser. (OffscreenBrowser.java:20)
at com.pdf.generator.PDFGenerator.fromHTML (PDFGenerator.java:62)
react-native version 0.59.9

Thanks for the beautiful library

@safapps
Copy link
Author

safapps commented Mar 11, 2020

Can someone help please?

@cesarvr
Copy link
Owner

cesarvr commented Mar 16, 2020

Hey @safapps

Sorry I haven't updated the plugin a while ago, I checked it yesterday and it seems that the API I use for the plugin are deprecated. When I get some free time I'll update it.

Cheers.

@cesarvr
Copy link
Owner

cesarvr commented Mar 17, 2020

Hi @safapps

I have updated the library to run on react-native so it should run now on Android >8, you just need to upgrade to the 1.5.0 version, this should do it:

npm install [email protected] -s

If you need an working example you can use this one...

Cheers.

@safapps
Copy link
Author

safapps commented Mar 20, 2020

@cesarvr Thank you very much for this quick response, I will update my project, your library is incredible and very light!

@safapps
Copy link
Author

safapps commented Mar 20, 2020

Hi @cesarvr after upgrading to version 1.5.0 still gave this error when testing on the Android emulator, the interesting thing is that it happens intermittently, most of the time it works correctly, this error in PDF.fromHTML, follow the message mistake:
"Calling display methods on a thread other than the user interface"
follow the screenshot of the error:
https://1drv.ms/u/s!AhJHgZvM402SgocGhhGlG4wN12AnDA?e=yC7nnq
https://1drv.ms/u/s!AhJHgZvM402SgocHEUeI28e4w1bi9A?e=lhpMBl
I'm sorry for the bad English

cesarvr pushed a commit that referenced this issue Mar 21, 2020
@cesarvr
Copy link
Owner

cesarvr commented Mar 21, 2020

Hey @safapps , I think I fix the problem for version 1.6.0, it was an issue was that the plugin was trying to do a lot of work in a thread that doesn't belong to UI rendering. I move those task where it belongs, so now It should work giving those errors/warning messages.

https://www.npmjs.com/package/rn-pdf-generator

@safapps
Copy link
Author

safapps commented Mar 22, 2020

error: cannot find symbol
import androidx.annotation.RequiresApi;

Hi @cesarvr , I can't test it, my application is breaking when compiling, because my react native version doesn't have androidx, is there any other way to import requiresApi other than androidx?
Thanks.

@cesarvr
Copy link
Owner

cesarvr commented Mar 23, 2020

That's because I upgraded the library to Androidx, you can do this:

  • Change manually the import package to use :
import android.support.annotation.RequiresApi;

Or you can upgrade your project to AndroidX and last version of react-native.

More info on upgrading

@cesarvr cesarvr closed this as completed Mar 26, 2020
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