question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

PDF Share crashes the app on Android

See original GitHub issue

Steps to reproduce

  1. Follow the steps from https://github.com/react-native-community/react-native-share#share-remote-pdf-file-with-gmail--whatsapp-ios using sharePDFWithAndroid
  2. 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:

screenshot 2019-02-18 at 18 24 31

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:closed
  • Created 5 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
mikehardycommented, Feb 19, 2019

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 😉

2reactions
mikehardycommented, Feb 19, 2019

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 😃

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found