Adaptive Icon not working

后端 未结 5 684
南旧
南旧 2021-02-05 13:16

manifest:



        
相关标签:
5条回答
  • 2021-02-05 13:58

    ic_launcher.xml should be like this

    <?xml version="1.0" encoding="utf-8"?>
    <adaptive-icon
        xmlns:android="http://schemas.android.com/apk/res/android">
        <background android:drawable="@color/white"/>
        <foreground android:drawable="@mipmap/ic_launcher_foreground"/>
    </adaptive-icon>
    
    0 讨论(0)
  • 2021-02-05 14:00

    I had issues getting my adaptive icon to display. Turns out I had done nothing wrong. It started working after I did a 'Clean Project' in Android Studio.

    0 讨论(0)
  • 2021-02-05 14:19

    I too have faced the same issue, here is how I have fixed this issue

    1. Right click on resource -> New -> ImageAsset

    2. Choose the ic_launcher_background icon and ic_launcher_foreground as shown in below screen

    1. Android studio creates an ic_launcher.xml under resource mipmap (anydpi-v26)

       <?xml version="1.0" encoding="utf-8"?>
      <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>
      
    2. Now inside the Manifest.XML, declare the icon and round icon something shown in like below

      <application
      android:allowBackup="true"
      android:icon="@mipmap/ic_launcher"
      android:label="@string/app_name"
      android:roundIcon="@mipmap/ic_launcher"
      android:supportsRtl="true"
      android:theme="@style/AppTheme">
      
      
                      .......</application>
      

      Yes that's all and Run your app on any device it appears

    0 讨论(0)
  • 2021-02-05 14:22

    Adaptive icon requied API 26 so you need to update your buildtools to at least 26.0.0 version

    0 讨论(0)
  • 2021-02-05 14:22

    I tried to debug it using an <ImageView>. When I did so, I got a backtrace ending with:

    Caused by: java.lang.IllegalArgumentException: Path string cannot be empty.
    

    Turns out my ic_launcher_foreground.xml had some <path> elements with empty android:pathData attributes.

    Deleting those empty <path>s made the icon work!

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