Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue when reading text file from Android Download folder with Android 11 #436

Closed
ASHBAW opened this issue Nov 18, 2020 · 5 comments
Closed

Comments

@ASHBAW
Copy link

ASHBAW commented Nov 18, 2020

Bug Report

Issue when reading text file from Android Download folder with Android 11

Problem

I have an Ionic 5 app that uses this plugin to read text files from the Download folder on Android devices. On devices running Android 11 it does not work. Devices running Android 9 do work - have not tried on Android 10.

What is expected to happen?

App should be able to read in text file from Android's Download folder

What does actually happen?

The promise for readAsText() returns null

Information

Run on devices with Android 11

Command or Code

Ionic app is using @ionic-native/file/ngx as a wrapper for the cordova-plugin-file plugin.

const path = this.file.externalRootDirectory + 'Download';

this.file.readAsText(path, 'foo.txt').then((file) => {
   console.log('process file');   
}).catch((e) => {
  console.log('error '+ e); 
});

Again this works for Android 9 devices (have not been able to try on a Android 10 device) but not 11.

Environment, Platform, Device

Ionic 5 with the following configuration

   Ionic CLI                     : 6.12.2 (/Users/.nvm/versions/node/v12.18.3/lib/node_modules/@ionic/cli)
   Ionic Framework               : @ionic/angular 5.4.3
   @angular-devkit/build-angular : 0.1002.0
   @angular-devkit/schematics    : 10.1.7
   @angular/cli                  : 10.2.0
   @ionic/angular-toolkit        : 2.3.3

Cordova:

   Cordova CLI       : 10.0.0
   Cordova Platforms : android 9.0.0, ios 6.1.1
   Cordova Plugins   : cordova-plugin-ionic-keyboard 2.2.0, cordova-plugin-ionic-webview 5.0.0, (and 15 other plugins)

Utility:

   cordova-res (update available: 0.15.2) : 0.15.1
   native-run (update available: 1.2.2)   : 1.0.0

System:

   ios-sim : 8.0.2
   NodeJS  : v12.18.3 (/Users/.nvm/versions/node/v12.18.3/bin/node)
   npm     : 6.14.8
   OS      : macOS Catalina
   Xcode   : Xcode 12.2 Build version 12B45b

Version information

Using "cordova-plugin-file": "^6.0.2"

Checklist

  • [ X ] I searched for existing GitHub issues
  • [ X ] I updated all Cordova tooling to most recent version
  • [ X ] I included all the necessary information above
@ASHBAW
Copy link
Author

ASHBAW commented Nov 18, 2020

Verified that a Pixel 3 running Android 10 like Android 11 does not wok. Android 9 and below does work.

@alex-steinberg
Copy link

This is already dealt with here: #426

@vincent-seibus
Copy link

Hello,
I have got the same problem on Android 10 / cordova 9 . Works with Android 10 / Cordova 8.1.

@jfoclpf
Copy link

jfoclpf commented Jan 11, 2021

Android blocked access to shared folders from API 29 (Android 10) due to privacy issues.
https://developer.android.com/reference/android/os/Environment#getExternalStorageDirectory()
I'm having the same issue to store a file in Downloads folder
https://stackoverflow.com/questions/65668470/how-to-save-a-file-on-shared-space-in-cordova-with-android

@breautek
Copy link
Contributor

Duplicate: #426

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants