Legacy icon does not show when using adaptive icon

前端 未结 4 1302
礼貌的吻别
礼貌的吻别 2020-12-25 12:24

I just converted my app icon to be compatible with android o\'s adaptive icons using the Image Asset Studio in android studio

when I run my project now

相关标签:
4条回答
  • 2020-12-25 12:59

    Solution is to have mipmap-anydpi-v26/ic_launcher.xml for adaptive icons applicable for API level 26 and above and for other API levels put ic_launcher.png (Note: Not ic_launcher.xml) in all mimpap folders.


    Explanation:

    Here is the basic problem mipmap-anydpi take precedence over all other mipmap-*. So if resource is found in mipmap-anydpi it will always take preference. Now mipmap-anydpi-v26 is a filter above this which says resources from mipmap-anydpi-v26 will always be picked irrespective of devices density only if API level is 26 or more (Oreo).

    Now you manifest has android:icon="@mipmap/ic_launcher"

    If your device has API level 26 or above android will choose to use mipmap-anydpi-v26/ic_launcher.xml and everything works fine.

    The problem happens when API level is less than 26. Android stats looking for resource named ic_launcher. It will never go and search in mipmap-anydpi-v26 because of API level constraint. Next, it would look for the resource in mipmap-anydpi and if not there then the actual density resource Eg. mipmap-mdpi.

    Next, you cannot give ic_launcher.xml to android devices less than sdk 26 because it does not know what adaptive icons is.

    So the solution is to have mipmap-anydpi-v26/ic_launcher.xml for adaptive icons applicable for API level 26 and above and for other API levels put ic_launcher.png (Note: Not ic_launcher.xml) in all mimpap folders.

    0 讨论(0)
  • 2020-12-25 13:00

    I had the same trouble, and solved it by renaming my mipmap-anydpi directory to mipmap-anydpi-v26.

    Apparently the ic_launcher.xml file confuses older Android versions, and this hides it from all but O. At any rate, my icons now work on all versions (down to SDK 11, at least).

    0 讨论(0)
  • 2020-12-25 13:06

    If still not working, check your XML schmema in , if you use auto import from Android studio, it will not work, it should be /apk/res/android. Here is the code:

    <adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
      <background android:drawable="@mipmap/ic_launcher_background"/>
      <foreground android:drawable="@mipmap/ic_launcher_foreground"/>
    </adaptive-icon>
    
    0 讨论(0)
  • 2020-12-25 13:13

    I have been faced same issue and resolved as below.

    Put your ic_launcher.xml and ic_launcher_round.xml should be in mipmap-anydpi-v26 (make sure you should not have ic_launcher.png/jpg or ic_launcher_round.png/jpg in same folder).

    Put your ic_launcher.png should be in mipmap-hdpi/mdpi/xhdpi/xxhdpi/xxxhdpi (make sure you should not have ic_launcher.xml and ic_launcher_round.xml in these same folder).

    By doing this, You will not get any errors building/running project.

    Hope it helps some one who are same issue...

    0 讨论(0)
提交回复
热议问题