1

I've added images to my drawable folder, namely, I've changed the image icon.png from the default to my custom image. I've also added a screen.png image

however when I try to load the image: <Image src="res://icon"></Image>

I still see the old default icon.png image and when I change the image source to screen then I get LOG from device Nexus 6P: Missing Image with resourceID: res://screen

I am using the tns preview command and using the NS Playground and NS Preview apps.

When I try to use a different approach, by adding the image to the assets/images/ folder, and refer to it as <Image src="~/images/icon.png"></Image> Then I get:

LOG from device Nexus 6P: Error in reading bitmap - java.io.FileNotFoundException: /data/data/org.nativescript.preview/files/app/images/icon.png (No such file or directory)

Can anyone offer some insight?

1
  • Changes to drawable folder requires a rebuild. Preview command do not build the app, it's just a quick way to test simple code. Commented May 9, 2020 at 13:49

1 Answer 1

3

I went with adding the image to the /assets/images folder and referred to it as: <Image src="~/assets/images/icon.png"></Image>

Sign up to request clarification or add additional context in comments.

2 Comments

You will have to build the application with tns [run|build] commands for changes on drawable folders to be effective.
Thank you , you saved me , it take more than one day to search this

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.