Hi all,

I have an app working fine on emulator, but I’ve encountered the following testing on a device (android, s9+):

/assets/hardcode/GenerateInitialUsers.txt:1 Failed to load resource: net::ERR_FILE_NOT_FOUND
vendor.js:1824 ERROR HttpErrorResponse
defaultErrorLogger @ vendor.js:1824

I get it a few times for a few different files, all .txt. They’re just some hardcoded sql insert statements and things that I’m setting up on the device for now, they’re a bit too long for typescript to transpile when I hardcoded them directly into the .ts, so I pulled them in first first this way. They’re saved in src\assets\hardcode*.txt. Does it actually bring those txt files over when it moves to the device (is there a way to check if they were dropped using DevTools/Inspect? Is there a better folder to put them in?

I’m generating the temp tables to pull from using the following (passing in the name of the table, the sql to create it and where the txt file is to do the insert to give it starting data), though like I said it works on the device and stepping through it show nothing unexpected sans error…

  GenerateTempLocalData(tableName: string, tableCreationText: string, sourceLocation: string): Promise<any>
    return this.db.executeSql('DROP TABLE IF EXISTS '+ tableName +';', {}).then(dres => {
    this.db.executeSql('CREATE TABLE IF NOT EXISTS '+ tableName +'('+ tableCreationText +');', {})
    .then((res) => {
    .catch(e => console.log(e + ' ERROR in creating ' + tableName + ' table'));
    this.httpClient.get('../../assets/hardcode/' + sourceLocation+ '.txt', {responseType: 'text'}).
    subscribe(data => {
      return this.db.executeSql(data, {}).catch(e => console.log(e));
  }).catch(e => console.log(e));

In case anyone has a chance to help me with this, I tried

this.filePath.resolveNativePath('../../assets/hardcode/' + sourceLocation+ '.txt')
    .then(filePath => console.log(filePath))
    .catch(err => console.log(err));

and it’s giving me “Unable To Resolve Filesystem Path”. Can’t find anything to correct this so it can though.
In DevTools under top / file:// / android_asset/www there is only build, plugins, index.html, cordova.js, cordova_plugins.js. I’m not seeing the file i’m attempting to read - is that indicative that they weren’t copied over?

I would try ‘./assets’ instead of ‘…/…/assets’. What you are trying to do with resolveNativePath is a complete dead-end, because assets live in a virtual filesystem baked into your app binary. They aren’t visible to the outside world.

Just for the hell of it I tried running every permutation I could think of

    this.httpClient.get('./../assets/hardcode/' + sourceLocation+ '.txt', {responseType: 'text'}).
    subscribe(data => {});
    this.httpClient.get('../assets/hardcode/' + sourceLocation+ '.txt', {responseType: 'text'}).
    subscribe(data => {});
    this.httpClient.get('./assets/hardcode/' + sourceLocation+ '.txt', {responseType: 'text'}).
    subscribe(data => {});
    this.httpClient.get('../../assets/hardcode/' + sourceLocation+ '.txt', {responseType: 'text'}).
    subscribe(data => {});
    this.httpClient.get('/assets/hardcode/' + sourceLocation+ '.txt', {responseType: 'text'}).
    subscribe(data => {});
    this.httpClient.get('assets/hardcode/' + sourceLocation+ '.txt', {responseType: 'text'}).
    subscribe(data => {});
    this.httpClient.get('/hardcode/' + sourceLocation+ '.txt', {responseType: 'text'}).
    subscribe(data => {});
    this.httpClient.get('hardcode/' + sourceLocation+ '.txt', {responseType: 'text'}).
    subscribe(data => {});
    this.httpClient.get('./hardcode/' + sourceLocation+ '.txt', {responseType: 'text'}).
    subscribe(data => {});

Same error for each though :\

Shouldn’t those textfiles be available and visible in DevTools at this point, even with lazy loading everything?


This is where I’m storing them…


Something is strange in your project, because I just put a file into src/assets/hardcode/afo.txt and this into the home page of a scratch project and it did what you would expect it to:

this.http.get("./assets/hardcode/afo.txt", {responseType: "text"})
  .subscribe(afo => this.afo = afo );

Under application when you’re debugging is it available under Application / Storage anywhere? I’m noticing that mine is empty.

Would you suggest something to troubleshoot this?

Lord have mercy I moved the hardcode folder into imgs, changed the reference to point to it and it worked

Why would this happen?

I wouldn’t expect it to be. That’s where IndexedDB stuff lives.

Looking under www/assets. If it’s not there, I would blow away the www directory entirely and rebuild. If it is there, I would generate a new project and just put this logic into it. If you get that working, you have a baseline to compare things with.