Getting crash on Android 11
See original GitHub issuejava.lang.IllegalArgumentException: fd cannot be null at Ua.onWrite(Unknown Source:187) at android.print.PdfConverter$1.onPageFinished(PdfConverter.java:71) at bC0.b(Unknown Source:10) at V9.handleMessage(Unknown Source:280) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:257) at android.app.ActivityThread.main(ActivityThread.java:8192) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:626) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1015)
2021-11-28 19:54:13.478 7756-7756/com.test.desk D/PdfConverter: Failed to open ParcelFileDescriptor java.io.FileNotFoundException: open failed: EACCES (Permission denied) at android.os.ParcelFileDescriptor.openInternal(ParcelFileDescriptor.java:344) at android.os.ParcelFileDescriptor.open(ParcelFileDescriptor.java:231) at android.print.PdfConverter.getOutputFileDescriptor(PdfConverter.java:154) at android.print.PdfConverter.access$100(PdfConverter.java:33) at android.print.PdfConverter$1.onPageFinished(PdfConverter.java:71) at bC0.b(Unknown Source:10) at V9.handleMessage(Unknown Source:280) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:257) at android.app.ActivityThread.main(ActivityThread.java:8192) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:626) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1015) 2021-11-28 19:54:13.479 7756-7756/com.test.desk W/om.test.des: Accessing hidden method Landroid/print/PrintDocumentAdapter$WriteResultCallback;-><init>()V (greylist, linking, allowed) 2021-11-28 19:54:13.486 7756-7756/com.test.desk D/AndroidRuntime: Shutting down VM
Getting crash whole generating pdf file.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:7
Top GitHub Comments
Go to android/src/main/java/com/christopherdro/htmltopdf/RNHTMLtoPDFModule.java line 68 and replace new File(Environment.getExternalStorageDirectory(), options.getString(DIRECTORY)) :
with new File(Build.VERSION.SDK_INT >= 30 ? mReactContext.getExternalFilesDir(null):Environment.getExternalStorageDirectory(), options.getString(DIRECTORY)) :
Please check, issue is fixed