Ionic-framework: Ionic 2 - image svg does not appear after build for Android

Created on 4 Dec 2016  路  1Comment  路  Source: ionic-team/ionic-framework

Ionic version: (check one with "x")
[ ] 1.x
[X ] 2.x

I'm submitting a ... (check one with "x")
[X ] bug report
[ ] feature request
[ ] support request => Please do not submit support requests here, use one of these channels: https://forum.ionicframework.com/ or http://ionicworldwide.herokuapp.com/

Current behavior:
I made the application build of the ionic 2 sidemenu, however the svg appears in the Chrome but svg does not appear in Android after generate the file android-debug.apk:

screenshot_2016-12-04-13-29-54

Follow the commands I used:

npm install -g ionic cordova
ionic start myApp --v2 sidemenu
ionic platform add android
ionic build android

/myApp/src/pages/page1/page1.html

<ion-header>
    <ion-navbar>
        <button ion-button menuToggle>
            <ion-icon name="menu"></ion-icon>
        </button>
        <ion-title>Page One</ion-title>
    </ion-navbar>
</ion-header>
<ion-content padding>
    <h3>Ionic Menu Starter</h3>
    <img src="../../assets/img/myapp.svg" alt="">
    <p>
        If you get lost, the
        <a href="http://ionicframework.com/docs/v2">docs</a> will show you the way.
    </p>
    <button ion-button secondary menuToggle>Toggle Menu</button>
</ion-content>

The svg file is on the following path /android-debug.apk/assets/www/assets/img/. If I swap the svg file for a png it works.

Expected behavior:
Appear image of svg file on Ionic 2 after build for Android

Most helpful comment

So the path is need to be "./assets/img/myapp.svg" intread "../../assets/img/myapp.svg" , because in a compiled app you are in the root , it's as if you are loading evething in the index.html file, and it's also works in the browser

http://stackoverflow.com/questions/40960428/ionic-svg-does-not-appear/40963067#40963067

Thank you, It worked now!!!

>All comments

So the path is need to be "./assets/img/myapp.svg" intread "../../assets/img/myapp.svg" , because in a compiled app you are in the root , it's as if you are loading evething in the index.html file, and it's also works in the browser

http://stackoverflow.com/questions/40960428/ionic-svg-does-not-appear/40963067#40963067

Thank you, It worked now!!!

Was this page helpful?
0 / 5 - 0 ratings