Skip to content

Android: Invariant Violation: TurboModuleRegistry.getEnforcing(...): 'RNDocumentPicker' could not be found. #837

@mustafasenturk

Description

@mustafasenturk

Feature description

Invariant Violation: TurboModuleRegistry.getEnforcing(...): 'RNDocumentPicker' could not be found. Verify that a module by this name is registered in the native binary.Bridgeless mode: false. TurboModule interop: false. Modules loaded: {"NativeModules":["PlatformConstants","LogBox","Timing","AppState","SourceCode","BlobModule","WebSocketModule","DevSettings","DevToolsSettingsManager","Networking","Appearance","DevLoadingView","HeadlessJsTaskSupport","UIManager","DeviceInfo","DeviceEventManager","ReanimatedModule","StatusBarManager","StatusBarManager","RNGestureHandlerModule","I18nManager","ImageLoader","SoundManager","IntentAndroid","NativeAnimatedModule","RNBootSplash","RNDatePicker","ReactNativeBlobUtil","RNCSafeAreaContext","RNPermissions","FileReaderModule","RNDatePicker"],"TurboModules":[],"NotFound":["NativePerformanceCxx","NativePerformanceObserverCxx","RedBox","BugReporting","LinkingManager","RNSModule","FrameRateLogger","KeyboardObserver","RNDocumentPicker"]}, js engine: hermes

[TypeError: Cannot read property 'NativeDocumentPicker' of undefined]

document-picker works correctly on ios but it cannot link correctly on android, I could not see the android configuration section in the documentation

{
  "name": "guris",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "android": "react-native run-android",
    "postinstall": "npx pod-install ios && sed -i '' '/PrivacyInfo.xcprivacy/d' ios/gurisapp.xcodeproj/project.pbxproj",
    "ios": "react-native run-ios",
    "lint": "eslint .",
    "start": "react-native start",
    "test": "jest",
    "bundle-android": "react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res"
  },
  "dependencies": {
    "@gorhom/bottom-sheet": "4.6.4",
    "@microsoft/signalr": "^8.0.7",
    "@react-native-community/geolocation": "^3.4.0",
    "@react-native-documents/picker": "^10.1.3",
    "@react-navigation/bottom-tabs": "^7.2.0",
    "@react-navigation/drawer": "^7.1.1",
    "@react-navigation/native": "^7.0.14",
    "@react-navigation/native-stack": "^7.2.0",
    "@reduxjs/toolkit": "^2.5.0",
    "@sentry/react-native": "^6.9.1",
    "axios": "^1.7.9",
    "base-64": "^1.0.0",
    "iconsax-react-native": "^0.0.8",
    "jwt-decode": "^4.0.0",
    "lottie-react-native": "5.1.6",
    "progress-hud": "^1.3.2",
    "react": "18.2.0",
    "react-native": "0.73.11",
    "react-native-base64": "^0.2.1",
    "react-native-blob-util": "0.19.4",
    "react-native-bootsplash": "4.7.5",
    "react-native-bouncy-checkbox": "^4.1.2",
    "react-native-circular-progress": "^1.4.1",
    "react-native-date-picker": "^5.0.8",
    "react-native-device-info": "^14.0.2",
    "react-native-dropdown-select-list": "^2.0.5",
    "react-native-element-dropdown": "^2.12.2",
    "react-native-floating-action": "^1.22.0",
    "react-native-geolocation-service": "^5.3.1",
    "react-native-gesture-handler": "2.21.2",
    "react-native-gifted-charts": "^1.4.47",
    "react-native-linear-gradient": "^2.8.3",
    "react-native-map-clustering": "^3.4.2",
    "react-native-maps": "1.14.0",
    "react-native-maps-directions": "^1.9.0",
    "react-native-mmkv": "2.12.2",
    "react-native-modal": "^13.0.1",
    "react-native-multiple-select": "^0.5.12",
    "react-native-pdf": "^6.7.7",
    "react-native-permissions": "^5.2.1",
    "react-native-reanimated": "3.16.6",
    "react-native-reanimated-carousel": "4.0.0-canary.22",
    "react-native-safe-area-context": "4.10.1",
    "react-native-screens": "4.0.0",
    "react-native-select-dropdown": "^4.0.1",
    "react-native-splash-screen": "^3.3.0",
    "react-native-svg": "^15.10.1",
    "react-native-vector-icons": "^10.2.0",
    "react-native-version-check": "^3.4.7",
    "react-native-video": "5.2.1",
    "react-native-virtualized-view": "^1.0.0",
    "react-redux": "^9.2.0",
    "redux-persist": "^6.0.0"
  },
  "devDependencies": {
    "@babel/core": "^7.20.0",
    "@babel/preset-env": "^7.20.0",
    "@babel/runtime": "^7.20.0",
    "@react-native/babel-preset": "0.73.21",
    "@react-native/eslint-config": "0.73.2",
    "@react-native/metro-config": "0.73.5",
    "@react-native/typescript-config": "^0.73.1",
    "@types/lodash": "^4.17.13",
    "@types/react": "^18.2.6",
    "@types/react-native-base64": "^0.2.2",
    "@types/react-native-version-check": "^3.4.8",
    "@types/react-native-video": "^5.0.20",
    "@types/react-test-renderer": "^18.0.0",
    "babel-jest": "^29.6.3",
    "babel-plugin-module-resolver": "^5.0.2",
    "eslint": "^8.19.0",
    "jest": "^29.6.3",
    "prettier": "2.8.8",
    "react-test-renderer": "18.2.0",
    "typescript": "5.0.4"
  },
  "reactNativePermissionsIOS": [
    "LocationWhenInUse"
  ],
  "engines": {
    "node": ">=18"
  },
  "packageManager": "yarn@3.6.4"
}

I am trying to select a file:


  const onAttachmentSelect = async (index: number) => {
    try {
      const maxLegalFileSize = 157286400;

      const pickerResult = await pick({
        type: [types.pdf, types.doc, types.docx],
        copyTo: 'cachesDirectory',
        mode: 'open',
      });

      const file = pickerResult[0];

      if (file.size && file.size > maxLegalFileSize) {
        Alert.alert(
          'Hata',
          "Dosya boyutu çok büyük. Lütfen 150 MB'den küçük dosya seçiniz.",
        );
        return;
      }

      const containsFileName = attachments.some(
        (att, attIndex) =>
          attIndex !== index && att.legalFileName === file.name,
      );

      if (containsFileName) {
        Alert.alert('Hata', 'Aynı isimde birden fazla ek dosyası eklenemez!');
        return;
      }

      const allowedTypes = ['pdf', 'doc', 'docx'];
      const fileExtension = file.name?.split('.').pop()?.toLowerCase();

      if (!fileExtension || !allowedTypes.includes(fileExtension)) {
        Alert.alert(
          'Hata',
          'Geçersiz dosya formatı. Lütfen bir PDF veya Word (.doc/.docx) dosyası seçin.',
        );
        return;
      }

      let fileUri = file.uri;

      if (!fileUri.startsWith('file://') && !fileUri.startsWith('content://')) {
        fileUri = `file://${fileUri}`;
      }

      console.log('Seçilen dosya bilgileri:', {
        name: file.name,
        uri: file.uri,
        finalUri: fileUri,
        size: file.size,
        type: file.type,
      });

      const updatedAttachments = [...attachments];
      updatedAttachments[index] = {
        ...updatedAttachments[index],
        legalFileName: file.name || '',
        fileUri: fileUri,
        isFileSizeMaximum: true,
        fileUploaded: false,
        isNewAttachment: true,
      };
      setAttachments(updatedAttachments);
    } catch (err) {
      if (isErrorWithCode(err)) {
        switch (err.code) {
          case errorCodes.OPERATION_CANCELED:
            console.log('Kullanıcı dosya seçimini iptal etti');
            break;
          case errorCodes.IN_PROGRESS:
            console.warn(
              'Birden fazla picker açıldı, sadece son açılan dikkate alınacak',
            );
            break;
          default:
            console.error('Dosya seçme hatası:', err);
            Alert.alert('Hata', 'Dosya seçilirken bir hata oluştu.');
        }
      } else {
        console.error('Dosya seçme hatası:', err);
        Alert.alert('Hata', 'Dosya seçilirken bir hata oluştu.');
      }
    }
  };

  

If there is any other information I need to add, I can add it.

What platform(s) should this be implemented on?

Android

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions