Android App Crash with react-native-pdf v6.7.7 after upgrading to Expo SDK 53 (RN 0.79.2 / React 19)
`import React, { useState, useRef } from 'react'; import { Modal, View, Platform, Alert, StyleSheet } from 'react-native'; import { Asset } from 'expo-asset'; import * as FileSystem from 'expo-file-system'; import Pdf from 'react-native-pdf'; // <-- Import causes issues when used import { Text, IconButton, Button } from 'react-native-paper';
// ... component setup, state, styles etc.
const openPdf = async (pdfModule) => { try { const asset = Asset.fromModule(pdfModule); await asset.downloadAsync(); const localUri = asset.localUri || asset.uri; let uriToLoad = localUri; // Handle content URI for Android if (Platform.OS === 'android' && localUri?.startsWith('file://')) { uriToLoad = await FileSystem.getContentUriAsync(localUri); } setSelectedPdfUri(uriToLoad); setModalVisible(true); // Reset page state... } catch (error) { console.error('Error loading PDF:', error); Alert.alert('Error', 'Could not load PDF.'); } };
// ... inside the component's return statement ...
<Modal animationType="slide" transparent={false} visible={modalVisible} onRequestClose={closePdf}
The app is working again now. I installed the library react-native-blob-util.