PDF Share crashes the app on Android
See original GitHub issueSteps to reproduce
- Follow the steps from https://github.com/react-native-community/react-native-share#share-remote-pdf-file-with-gmail--whatsapp-ios using
sharePDFWithAndroid
- Execute
This is my own code which is similar:
const share = () => {
const uri = 'https://www.apple.com/support/products/pdf/applecare_ipod_t_and_c_11182003.pdf';
const type = 'application/pdf';
RNFetchBlob.config({
fileCache: true,
})
.fetch('GET', uri)
.then(resp => {
return resp.readFile('base64');
})
.then(async base64Data => {
const url = `data:${type};base64,` + base64Data;
await Share.open({ url });
});
};
Expected behaviour
The Share panel opens
Actual behaviour
The application crashes with the following error:
Works fine on iOS.
Environment
- React Native version: 0.58
- React Native platform + platform version: Android 9
react-native-share
Version: 1.1.3
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
PDF Share crashes the app on Android · Issue #452 - GitHub
Works fine on iOS. Environment. React Native version: 0.58; React Native platform + platform version: Android 9. react-native-share. Version: ...
Read more >Android app crashes when opening pdfs - Paperpile Forum
Hello, I've installed the android app (1.3.2) from store and syncs fine, but when trying to open a pdf, it crashes.
Read more >android - After opening PDF with intent, app crashes with ...
I've discovered that as long as I save the pdf to the Downloads Directory, it fixes it for my situation ... setDataAndType(path, "application/pdf");...
Read more >App keeps crashing - Adobe Support Community - 11361265
It is doing this when I go to open any and all PDF. I'm using a samsung Galaxy S8 active model SM-G892A, android...
Read more >PDF reading crashes in ANDROID tablet - Dropbox Community
Hi all, I have a Samsung Note Pro tablet running the last version of Android. Since the last Dropbox update, behaviour when reading...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Predictably, me not following the docs was the root cause (https://github.com/react-native-community/react-native-share/pull/197) - users are terrible aren’t they? Never following the docs 😉
Last followup in case someone lands here from google searching for the error message. If you see
'undefined is not a function (evaluating 'Object.keys(styles)[typeof Symbol === "function" ? Symbol.iterator: "@@iterator']()]')
as an error message, it is an as-yet-unreported bug in react-native/Libraries/Promise.js where the ‘pretty-print’ library is messing up error message display.If you replace the line in Promise.js that requires pretty-print with a straight print of error.message you will see the unmasked message is that there is a possible unhandled Promise rejection.
And if you think through that, you will realize that you probably have an async function in your code, with a try/catch block that looks right, but in your try block you forgot to actually await on whatever API you called that returns a Promise. You just called the API directly with no await keyword. So the Promise rejection is not handled and you need to study Javascript async/await more to improve your skills. And you also need to fix whatever is causing the rejection but that’s also a problem in your code. Good luck 😃