I suddenly faced this issue when I tested this on Android Q device for the Print PDF feature. Its was working fine till Android P. I tried finding solution on the internet but of no use. Any help would be good.
Fatal Exception: java.lang.IllegalArgumentException fd cannot be null in onwrite() of PrintAdapter class in Android Q only
2.1k Views Asked by Prajwal Waingankar At
2
There are 2 best solutions below
0
Jr'Z
On
I've had this issue when upgrading to API Level 31.
It came from the fact that, in the pdfprint class I had, there was a line of code with a :
if (file.createNewFile()) {
return ParcelFileDescriptor.open(file,
ParcelFileDescriptor.MODE_READ_WRITE); }
By adding a code that removed the file before creating it, it just worked fine
if (file.exists()) file.delete();
if file.createNewFile()
return ParcelFileDescriptor.open(file, ParcelFileDescriptor.MODE_READ_WRITE);
The code I used was based on one I found on Internet, so I did not take time to get the opportunity to clean it up, but it's what solved that issue to me.
Related Questions in JAVA
- Add image to JCheckBoxMenuItem
- How to access invisible Unordered List element with Selenium WebDriver using Java
- Inheritance in Java, apparent type vs actual type
- Java catch the ball Game
- Access objects variable & method by name
- GridBagLayout is displaying JTextField and JTextArea as short, vertical lines
- Perform a task each interval
- Compound classes stored in an array are not accessible in selenium java
- How to avoid concurrent access to a resource?
- Why does processing goes slower on implementing try catch block in java?
- Redirect inside java interceptor
- Push toolbar content below statusbar
- Animation in Java on top of JPanel
- JPA - How to query with a LIKE operator in combination with an AttributeConverter
- Java Assign a Value to an array cell
Related Questions in ANDROID
- Delay in loading Html Page(WebView) from assets folder in real android device
- MPAndroidChart method setWordWrapEnabled() not found
- Designing a 'new post' android activity
- Android :EditText inside ListView always update first item in the listview
- Android: Transferring Data via ContentIntent
- Wrong xml being inflated android
- AsyncTask Class
- Unable to receive extras in Android Intent
- Website zoomed out on Android default browser
- Square FloatingActionButton with Android Design Library
- Google Maps API Re-size
- Push toolbar content below statusbar
- Android FragmentPagerAdapter Circular listview
- Layout not shifting up when keyboard is open
- auDIO_OUTPUT_FLAG_FAST denied by client can't connect to localhost
Related Questions in PRINTING
- How to send ESC/POS commands to thermal printer in Linux
- JTable Printing. How to set page breaks programmatically?
- Why do print and echo behave differently in a "for" loop
- Is there a way to limit the html page to a particular page size?
- How to execute keybord shortcut CTRL + P by clicking a link using jquery
- Chrome print preview disable only link location in footer and header
- C program doesn't print
- how to print a receipt to a particular printer
- How to print Jasper reports from servlets?
- Is it possible to print web content on thermal printer?
- How to print the HTML in Java
- How to get a response of file printing job to user from printer using CUPS in linux
- Android PrintManager get callback
- Business card height and width in pixels on web?
- Microsoft Dynamics Ax 2012 R2 run time issue
Related Questions in ANDROID-10.0
- How to pick video or image from gallery and get its path according to Android 10 (API Level 29) as Mediastore.Video.Media.DATA is deprecated
- Keep file after wipe data in Android 10
- Android 10 Bluetooth disconnecting background services
- Different Android Id in Android 10
- Change default sms app intent not working on android 10
- Flutter webview black screen when keyboard is popping up
- Xamarin: Saving files to external storage on Android with an API level >=29
- How to merge video and audio into one file [Android Q]
- How to make connection to the device in wifi via android app..I need persistent connection (That is does not lost after exiting the app)
- How to write a file to external storage in Android 10 using Android Studio
- ACTION_SET_ALARM from service on Android 10+
- Write permissions not working - scoped storage Android SDK 30 (aka Android 11)
- Call Recording is Available or Not in Android 10?
- how open activity from ForegroundService when phone is locked and screen is off in android 10?
- Xamarin.Plugin.FilePicker - content:/com.android.providers.downloads.documents Problem
Related Questions in ANDROID-PRINT-MANAGER
- How do I print programatically on android without the prompt where you have to choose a printer?
- How to set up printing in android without calling the printManager.print triggering the print_dialog_intent?
- Android: How to print to Default Print Service without Android UI?
- can to print pdf using predefined print framework?
- Android PrintDocumentAdapter remove/hide save as pdf option
- Android - Printing PDF file with added printer
- How I can activate color option in print dialog?
- How to configure Build In POS printer with android PrintService
- How to open custom Application when Clicking Print Button From Chrome In Android
- How to print password protected PDF in android?
- Print Manager is now showing save to PDF when printer is connected
- Malformed PDF print doesn't catch RuntimeException
- Do Android apps need to add any dependency in order to support CUPS (Common Unix Printing System/Server)
- Print PDF files using network printer in Android
- Android PrintManager: process gets killed, print outputs file of zero bytes length
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
I got the solution to this by refering the official documentation here: Android 10 Privacy
We have to add:
in the application tag of the manifest file for versions >= 29.
The documentation:Although, from the article is has stated that from Android 11, the scoped storage will be introduced and therefore from Android 11, this work around wont be possible.
here,
So you will have to mandatorily jump to scoped storage for >= Android 11.
Hope this solution helps someone.
====================
Solution 2:
If above didnt worked than the only reason is that you haven't provided Read/Write permission in your android app. Add permission logic in code and reinstall app -> give permission and it works!