I can’t set a vector image as an app icon

Asked

Viewed 276 times

2

As you can see I’ve correctly added a svg. so that it acts in a vector way:

inserir a descrição da imagem aqui

The problem happens when I try to put it as app icon:

inserir a descrição da imagem aqui

I go to Androidmanifest.xml and normally modify the line android:icon="@drawable/ic_tree" just like I do with a drawable normal:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="genesysgeneration.svg">

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_tree"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

I thought I’d have to do something different after I saw it didn’t work out, but the app doesn’t give me any other choices:

inserir a descrição da imagem aqui

inserir a descrição da imagem aqui

I tried to put the image inside the mipmap folder as indicated, but it was wrong:

inserir a descrição da imagem aqui

  • Creates the mipmap folder and place the icon there. It is the new Android standard.

  • You made an error... I edited the question by presenting it.

  • Well I’ll try later, never tried to use vector in mipmap. But it is sure that android adopts this new standard.

  • What is the minSdkVersion and the targetSdkVersion for the app? What version of android is running on emulator?

  • 15 and 25 respectively... (4.0.3 ice cream Sand...) and (7.1 nougat)

  • I tested on 9, 16 and 25 and it works. Update/Use the latest versions of Android Studio, Build Tools, build:Radle tools and Support Library.

  • I updated the android studio, the error to put in mipmap is gone, but still does not show the correct icon

  • I would like to use API 15 anyway, because I am more used to it and it is from it that there are most users.

  • 1

    In my answer to your question Error trying to display a vector image (SVG)! do not use what is described in Note 1, see Note 2.

  • Please post the icon file, so you can test it here. To help you...

  • https://uploaddeimagens.com.br/imagens/tree-svg

Show 6 more comments

1 answer

0

Try so save the file in the drawable folder then click with the right mouse and create an Asset Vector:

Vector Asset


Another way!

Well... to make it easier there is this site "Inside the link . txt" that converts any image into Andoid Studio icon.

Annex: Archives

I’ll explain how I did it:

  1. I downloaded your file (.svg) as png.
  2. I went to the site I passed and skipped the image.
  3. I defined the null fund (transparent).
  4. I saved... in which I generated a ZIP (with a res folder)
  5. Then replace in the project in the mipmap folders: (see attachment to project image)
  6. Generating this result: (see the emulator print attachment)

Any questions you may ask!!!

  • I made it man and nn worked

  • tbm tried to create xml in mipmap, but it creates right in drawable

  • about svg, create it in drawable, but it was an error and I was forced to put it in raw folder

  • added a new method to the answer (Edit)

  • opa, I have that same image in png, I would really like to know if it can put it as icon of the app being svg

  • So I tried on that site the SVG you sent but it cuts the image I believe that this very high the resolution... look here -> [link] (https://romannurik.github.io/AndroidAssetStudio/index.html) .

  • yes, I thought about it because of the different resolutions between devices

Show 2 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.