File.readAsText never resolves

sure it is, I’m debugging in an emulator with chrome inspect, although the Android SDK itself vary between platforms, probably the issue is there… but yeah, thanks for your time.

1 Like

oki doki … for the record I tested this today on both iOS and Android real phone … just in case

Thank you! I was looking for exactly this information :+1:

1 Like

Hello, I got this issue sometimes, not always and I can’t figure why yet.
We use FileTransfer, Zip and File from Ionic native.
My code looks like this:

const fileTransfer: FileTransferObject = self.transfer.create();
fileTransfer.download(url, file.dataDirectory + FILE_NAME)
	.then(() => {

		self.zip.unzip(file.dataDirectory + FILE_NAME, file.dataDirectory)
			.then((result) => {

			if (result == 0) {
					
					// Always get here but sometimes, readAsText never resolves...
					
					file.readAsText(this.file.dataDirectory, NOM_FICHIER_XML)
						.then((data) => {
							
						})
						.catch((Error) => {
							
						})
			}
		}
	}

ionic info:

cli packages: 

    @ionic/cli-utils  : 1.13.0
    ionic (Ionic CLI) : 3.13.0

global packages:

    cordova (Cordova CLI) : 7.1.0

local packages:

    @ionic/app-scripts : 3.0.0
    Cordova Platforms  : android 6.3.0
    Ionic Framework    : ionic-angular 3.7.1

System:

    Android SDK Tools : 26.0.1
    Node              : v6.9.5
    npm               : 4.2.0
    OS                : Windows 7

Config.xml:

<plugin name="cordova-plugin-file" spec="4.3.3" />
<plugin name="cordova-plugin-zip" spec="3.1.0" />
<plugin name="cordova-plugin-file-transfer" spec="1.6.3" />

Package.json:

"@ionic-native/file": "4.3.1",
"@ionic-native/file-transfer": "4.3.1",
"@ionic-native/zip": "4.3.1",

The workaround about placing cordova.js after polyfills.js works for us, but it kind of break the splash screen (where the splash screen is rapidly replaced with a gray background at startup).

Any idea why the File.readAsText() doesn’t resolve sometimes ?

Thanks.

Hey.
can you explain how to read file using http?

@seevoovapp, like this;

this.http.get(yourFile)
.map((res: Response) => res.text())
.subscribe(data => {
// data is the content of your file
//do something with it
},
error => {
console.log("Error reading config file " + error.message + ", " + error.code);
})

Still have this Problem

ionic info

cli packages: (/usr/lib/node_modules)

    @ionic/cli-utils  : 1.19.0
    ionic (Ionic CLI) : 3.19.0

global packages:

    cordova (Cordova CLI) : 7.1.0 

local packages:

    @ionic/app-scripts : 3.1.0
    Cordova Platforms  : android 6.3.0
    Ionic Framework    : ionic-angular 3.9.2

System:

    Node : v6.12.0
    npm  : 3.10.10 
    OS   : Linux 4.13

Environment Variables:

    ANDROID_HOME : not set

Misc:

    backend : pro

This issue is replicated again after the android webview updated to 63.xxx

Try to put some Timeout and test.

Hi

problem with me as well. Used to work, now not anymore. Switching cordova.js against polyfill.js in index.html seems to fix it (Android Tablet). Such a horrible bug to find and thank you all here for publishing the fix!

C:\Gebruikers\Developer\xxxx>ionic info

cli packages: (C:\Users\xxxxAppData\Roaming\npm\node_modules)

    @ionic/cli-utils  : 1.19.1
    ionic (Ionic CLI) : 3.19.1

global packages:

    cordova (Cordova CLI) : 7.0.1

local packages:

    @ionic/app-scripts : 3.1.8
    Cordova Platforms  : android 6.2.3
    Ionic Framework    : ionic-angular 3.9.2

System:

    Node : v6.11.2
    npm  : 5.6.0
    OS   : Windows 7

Environment Variables:

    ANDROID_HOME : C:\Gebruikers\Developer\Android\Android\sdk

Misc:

    backend : pro

1 Like

Any news on that issue? Importing cordova.js after polyfills.js seems to work but i’me not sure if that could cause other side effects.

@ionic-native/file”: “^4.19.0”

1 Like

polyfills.js
cordova.js

in that order incredibly it works

1 Like