react-native-file-viewer icon indicating copy to clipboard operation
react-native-file-viewer copied to clipboard

[Unhandled promise rejection: TypeError: null is not an object (evaluating 'RNFileViewer.open')]

Open ssengedonazil opened this issue 3 years ago • 9 comments

thnks alot ,but this has made me having sleepless night to any one ever come a close such

ssengedonazil avatar Nov 25 '21 13:11 ssengedonazil

which OS? which RNFV version?

code-by avatar Nov 26 '21 22:11 code-by

Android as platform and version of 2.1.4

ssengedonazil avatar Nov 26 '21 23:11 ssengedonazil

please also provide your code

code-by avatar Nov 28 '21 20:11 code-by

I am facing this issue as well. Here is my implementation. (PS: I am using redux-saga)

*openFile({ payload }, { select, call, put, all }) {
        const { url, fileName } = payload;

        const localFile = `${RNFS.DownloadDirectoryPath}/${fileName}`;
        const fileUrl = `${Config.API_URL}${url}`;

        FileViewer.open(localFile, { showOpenWithDialog: true });  <--- crash

When I open the document, the intent activity seems to be crashed. Then, I debug it using Android Studio, and I got the following error.

E/RNDocumentPicker: promise was null in onActivityResult

Current Android Config: Android SDK: 30 RN version: 0.66.0

Any idea which part I am missing out?

Editted: Poco X3 NFC (Android 11) is working fine. Pixel 4 emulator (Android 11) keep crashing.

WenLonG12345 avatar Nov 30 '21 07:11 WenLonG12345

I am also facing this issue in both iOS and Android. App crash when open file, Below is my code. RNFS.downloadFile(fileOptions) .promise.then(() => { FileViewer.open(localFile) .then(() => { console.log('Rileviewer sucess, '); }) .catch(error => { // error console.log('FileViewer error - ', error); }); })

Thanks,

RushirajJhala avatar Nov 30 '21 11:11 RushirajJhala

in react native +0.60 just run in your command prompt npm i and rebuild your project this works for me you don't have to manually link this library

Khubaib-Sarfraz avatar Dec 03 '21 12:12 Khubaib-Sarfraz

Android as platform and version of 2.1.4

@ssengedonazil could you share a snippet of your code showing how you import the library? It could also be related to some issues regarding the linking of the library.

vinzscam avatar Dec 12 '21 21:12 vinzscam

I am facing this issue as well. Here is my implementation. (PS: I am using redux-saga)

*openFile({ payload }, { select, call, put, all }) {
        const { url, fileName } = payload;

        const localFile = `${RNFS.DownloadDirectoryPath}/${fileName}`;
        const fileUrl = `${Config.API_URL}${url}`;

        FileViewer.open(localFile, { showOpenWithDialog: true });  <--- crash

When I open the document, the intent activity seems to be crashed. Then, I debug it using Android Studio, and I got the following error.

E/RNDocumentPicker: promise was null in onActivityResult

Current Android Config: Android SDK: 30 RN version: 0.66.0

Any idea which part I am missing out?

Editted: Poco X3 NFC (Android 11) is working fine. Pixel 4 emulator (Android 11) keep crashing.

@WenLonG12345 your issue could be related to this

vinzscam avatar Dec 12 '21 21:12 vinzscam

Hi sorry for the late reply, I had implement the Package Visibility but still no luck. The native error promise was null in onActivityResult still exist. Any idea why this happen?

WenLonG12345 avatar Mar 17 '22 10:03 WenLonG12345