Search code examples
angularnativescript

Nativescript 7 - Image Tag Error: java.io.FileNotFoundException (Images not Loading)


Images aren't loading.

I'm getting the error:

Error in reading bitmap - java.io.FileNotFoundException: /data/data/org.nativescript.testdemo/files/app/images/testimage.png (No such file or directory)

The folder structure "appears" fine but clearly both iOS and Android are not seeing the images.

so, I added 'images' to the assets folder and also tried adding the following line in webpack.config.js to see if it would use the images folder:

{ from: 'images/**', noErrorOnMissing: true, globOptions: { dot: false, ...copyIgnore } },

HTML is set like this:

<Image src="~/images/testimage.png"></Image>

Also tried the variant to no avail (after placing the images folder inside the assets folder):

<Image src="~/assets/images/testimage.png"></Image>

I also tried configuring webpack.config.js per the Github link below.

GitHub Issue

I'm running: Nativescript 7.0.10 Angular 10.1.0

package.json

"@nativescript/android": "7.0.0",
"@nativescript/ios": "7.0.3",

Solution

  • This fixed it for me.

    Unfortunately, there's no documentation that specifies this change.

    I moved the assets, fonts, and my images folder to the src directory.

    old folder structure:

    src
    - assets
    - images
    - fonts
    

    new folder structure:

    src
    - app
    assets
    images
    fonts