Cordova object is undefined on Android app
-
Hey! I have an built Android app that it can’t to access to cordova object, it appears undefined. I want to use the cordova-plugin-file to download files but it doesn’t work since this error. I’ll apreciate your help
-
This post is deleted! -
How and where are you trying to access the cordova object? If you post code samples people here will be able to help you better.
btw here’s the plugin’s doc:
https://cordova.apache.org/docs/en/latest/reference/cordova-plugin-file/Did you try:
window.cordova
-
@dobbel said in Cordova object is undefined on Android app:
How and where are you trying to access the cordova object? If you post code samples people here will be able to help you better.
btw here’s the plugin’s doc:
https://cordova.apache.org/docs/en/latest/reference/cordova-plugin-file/Did you try:
window.cordova
This is a download file method
this.$api.get(`file2/${fileName}`, { responseType: 'blob' }).then(res => { console.log('respondio', this.$q.platform.is.desktop) var blob = new Blob([res]) this.saveBlob2File(fileName, blob) this.$q.dialog({ title: 'err', message: this.$q.platform }) // this.$q.loading.hide() if (this.$q.platform === undefined) { console.log('aqui') this.saveBlob2File(fileName, blob) } }).catch(function (err) { })
The above method calls to saveBlob2File function
saveBlob2File (fileName, blob) { // var vm = this this.$q.dialog({ title: 'saveBlob2File', message: window.cordova }) this.$q.dialog({ title: 'saveBlob2File2', message: this.$q.cordova }) this.$q.dialog({ title: 'saveBlob2File3', message: cordova }) var folder = cordova.file.externalRootDirectory + 'Download' window.resolveLocalFileSystemURL(folder, function (dirEntry) { console.log('file system open: ' + dirEntry.name) this.createFile(dirEntry, fileName, blob) }, this.onErrorLoadFs) }
There is 3 dialogs modal, it shows undefined three times
-
Looking at your code I can’t come up with any reason why it’s undefined.
a few things you can try:
-
remove the plugin , and install it again . ( make sure it it really gone from the FileSystem and in the config.xml and/or package.js inside src-cordova)
-
remove the android platform completely. and add it again
-
make a github repo so I or someone else could try it out.
-
-
@iamyohanarias I guess you solved your problem.
-
@dobbel Yes my friend. I deleted the plugin and I was reinstall it. Thank you for tour help