Image not appearing in Android App


#1

Hello, i’m using ion-slides to show a basic tutorial of my App. So, i’m using some elements that are in a image and to show a part of image i’m using the sprite technique . I did the page based in my browser view and the final style in browser was:


However, i built the .apk (Android) and ran the App and the images didn’t apper. Can someone help me? I googled but didn’t find anything. Here is my CSS and .html that i wrote: pastebin

Waiting for replies, Lucas.


#2

assets folder resides under the www folder. So try this for your paths to the images /assets/img/yourfancypic.jpeg


#3

Examples:

  1. path to image in html file: <img src="assets/img/pattern.png">
  2. path to image in scss file: background-image: url('../assets/img/pattern.png')

#4

I have the same issue.
In ionic serve it is OK, but when I gor for ionic view app or build the apk. the images does not appear.
Thanks for any one can help us.


#5

Let’s suppose you have an image file “myImage.jpg”. Copy this file to the folder ‘src/assets/img/’. Now you can use the path in 3 different places:

1. html file: <img src="assets/img/myImage.jpg">
2. scss file: background-image: url('../assets/img/myImage.jpg')
3. ts file: this.pathToImage = "assets/img/myImage.jpg";

#6

Thanks for the reply pe1. I did this. Indeed it work when I run ionic serve in the browser, however it does not work when I build .APK or run into ionic view.