Skip to content

Android 14: Error: Download manager download failed, the file does not downloaded to destination. #330

Open

Description

@DmytroKlimchuk

Package.json

    "react": "18.2.0",
    "react-native": "0.73.2",
    "react-native-blob-util": "0.19.4",

Build params:

        buildToolsVersion = "34.0.0"
        minSdkVersion = 21
        compileSdkVersion = 34
        targetSdkVersion = 34
        ndkVersion = "25.1.8937393"
        kotlinVersion = "1.8.0"

When I try to download the file I get an error (Error: Download manager download failed, the file does not downloaded to destination.), but the file itself is downloading
Z5OssD5

const BASE_DIR = Platform.OS === 'ios' ? RNFetchBlob.fs.dirs.CacheDir : RNFetchBlob.fs.dirs.DownloadDir;
const filePath = `${BASE_DIR}/${fileName}`;

const isExist = await RNFetchBlob.fs.exists(BASE_DIR);

if (isExist) {
  return RNFetchBlob.config({
        addAndroidDownloads: {
          useDownloadManager: true,
          notification: true,
          description: `${t('Downloading file')}...`,
          path: filePath,
          title: fileName,
          mediaScannable: true,
        },
        overwrite: true,
        fileCache: true,
        indicator: true,
        path: filePath,
      }).fetch(method, path, headers, body);
}

Logcat details:
muUwhBr

Activity

  1. anastobe commented on Jan 22, 2024

    @anastobe

    same issue any solution?

  2. danish5454 commented on Jan 22, 2024

    @danish5454

    facing same issue while downloading.....

  3. marcelormourao commented on Jan 25, 2024

    @marcelormourao

    Same issue here. It seems to fail only in Android 14.

  4. danish5454 commented on Jan 25, 2024

    @danish5454

    @marcelormourao no Its also fail on Android 13 devices as well.
    initially I'm facing Cannot read property 'rnfbEncode' of undefined to fix this I wrap the path with ReactNativeBlobUtil.wrap(path) but when downloading start its save on download folder but also its showing me Download manager download failed.

  5. imdangle commented on Jan 29, 2024

    @imdangle

    The same problem happened! But after downgrading to react-native-blob-util@0.19.4 based on this this
    Everything is working again! But still need to look into that issue.

  6. NishantZet commented on Feb 5, 2024

    @NishantZet

    @dangleh Did you figured out any solution for this ?

  7. mollyOver commented on Feb 9, 2024

    @mollyOver

    using 0.19.4 isn't working for me. I am getting same issue. File is downloaded, but getting the download manager error.
    I can see the file in the my app's download folder, but from the download manager pop-up it says "can't open file".
    I tried writing to root Download folder, but seeing same behavior.
    I have RN 0.73.3 and API Level = 33, means I should care about the permissions.

  8. danish5454 commented on Feb 27, 2024

    @danish5454

    version 0.19.8 also shave same issue

  9. NishantZet commented on Feb 27, 2024

    @NishantZet

    version 0.19.8 also shave same issue

    Downgrading to version 0.19.4 worked for me, make sure you are now using ^for the package

  10. AntonyARHS commented on Apr 5, 2024

    @AntonyARHS

    Having the issue with 0.19.4 too. The image is correctly downloaded but still have this error...

  11. NishantZet commented on Apr 5, 2024

    @NishantZet

    @AntonyARHS can you share your package.json file?

  12. usama-homage commented on Apr 15, 2024

    @usama-homage

    0.19.9 have same issue

  13. Haider-Ali-7 commented on Jun 3, 2024

    @Haider-Ali-7

    Can you try using react-native-blobl-util package instead of rn-fetch-blob as rn-fetch-blob is not maintained anymore.

    export const onFileDownload = async (uri, callback) => {
      const fileName = uri?.split("/")?.pop();
      const { dirs } = RNBlobUtil.fs;
      const dirToSave = isIOS ? dirs.DocumentDir : "/storage/emulated/0/Download";
      const path = `${dirToSave}/${fileName}`;
    
      RNBlobUtil.config({
        fileCache: true,
        path: path,
        appendExt: "pdf",
        overwrite: true,
        addAndroidDownloads: {
          useDownloadManager: true,
          notification: true,
          mediaScannable: true,
          title: fileName,
          description: "Downloading file",
          path: path,
        },
      })
        .fetch("GET", uri)
        .then((res) => {
          if (isIOS) {
            callback && callback();
            RNBlobUtil.fs.writeFile(path, res.data, "base64");
            RNBlobUtil.ios.previewDocument(path);
          }
    
          if (isAndroid) {
            callback && callback();
            showToast("File downloaded");
          }
        })
        .catch((e) => {
          showToast(e?.message);
          console.log("file save ERROR", e.message);
        });
    };
    
  14. jedaydiya commented on Sep 27, 2024

    @jedaydiya

    Any updates on this?
    Encountering the same issue. It just downloads in Android/Data the folder of the app

  15. denysoleksiienko commented on Jan 24, 2025

    @denysoleksiienko

    Same issue. Any update?

  16. CamiloGallegoM commented on Feb 7, 2025

    @CamiloGallegoM

    I have the same problem, does anyone know of any progress on this issue?

  17. kartikbhalla12 commented on May 14, 2025

    @kartikbhalla12

    For anyone else having this issue, the issue comes when we extract the filePath from the url and pass it in the config. if we url has spaces (%20 when encoded), it throws this error.

    try decoding it before passing to the config of blob util.

    path: decodeUri("/abc/filename%20extracted%20from%20url.pdf")

    it will resolve to

    path: "/abc/filename extracted from url.pdf"

    this worked for me.

  18. izakarzheieva commented on Nov 27, 2025

    @izakarzheieva

    remove fileCache: true resolved for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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