Skip to content

[Android] keepLocalCopy hangs after app restart and never resolves #907

@CatLover01

Description

@CatLover01

I have searched open and closed issues for this issue.

  • I have searched open and closed issues.

I have read and understood the license (link below).

  • I have read and understood the license.

Minimal reproducible example

const [copyResult] = await DocumentPicker.keepLocalCopy({ files: [ { uri: img.uri, fileName: img.name ?? 'image', }, ], destination: 'documentDirectory', });

What platform(s) does this occur on?

Android

Did you reproduce on a real device or emulator / simulator?

real device

Steps to reproduce

When the app is initially installed or launched, the functionality works as expected, users can select images, and they are successfully copied locally. However, after the app is fully terminated (removed from memory) and then reopened, the keepLocalCopy function becomes unresponsive: it hangs indefinitely and neither resolves nor throws any error or exception.

const newImages = await DocumentPicker.pick({
  type: [DocumentPicker.types.images],
  allowMultiSelection: true,
  mode: 'import',
  allowVirtualFiles: true,
});

if (newImages && newImages.length > 0) {
  let localURIs: string[] = [];
  for (const img of newImages) {
    // Hangs here forever after app is reopened
    const [copyResult] = await DocumentPicker.keepLocalCopy({
      files: [
        {
          uri: img.uri,
          fileName: img.name ?? 'image',
        },
      ],
      destination: 'documentDirectory',
    });

    if (copyResult.status === 'success') {
      localURIs.push(copyResult.localUri);
    }
  }
}

If the issue is related to specific file(s), I have linked the files so that others can reproduce exactly what I see.

  • I have attached files necessary to reproduce the problem (if applicable).

Stacktrace of the crash (if applicable)

None

Your computer environment

System:
  OS: Linux 6.12
  CPU: (16) x64 11th Gen Intel(R) Core(TM) i7-11700 @ 2.50GHz
  Memory: 30.04 GB / 62.44 GB
  Shell:
    version: 5.2.37
    path: xxx/bin/bash
Binaries:
  Node:
    version: 24.3.0
    path: xxx/bin/node
  Yarn:
    version: 4.12.0
    path: /usr/bin/yarn
  npm:
    version: 11.4.2
    path: xxx/bin/npm
  Watchman:
    version: 2025.04.21.00
    path: /usr/bin/watchman
SDKs:
  Android SDK:
    API Levels:
      - "35"
      - "36"
    Build Tools:
      - 35.0.0
      - 36.0.0
    Android NDK: 27.1.12297006
IDEs:
  Android Studio: Not Found
Languages:
  Java:
    version: 17.0.15
    path: /usr/bin/javac
  Ruby: Not Found
npmPackages:
  "@react-native-community/cli":
    installed: 17.0.0
    wanted: ^17.0.0
  react:
    installed: 19.1.0
    wanted: 19.1.0
  react-native:
    installed: 0.81.5
    wanted: 0.81.5
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: true

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions