Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Element adaptive-icon must be declared

I use Android Studio 2.3.3 stable and trying to create adaptive icon for Android O

I've created folder mipmap-anydpi-v26 and file ic_launcher.xml with following content

<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
    <background android:drawable="@color/colorAccent"/>
    <foreground android:drawable="@drawable/ic_launcher_adaptive"/>
</adaptive-icon>

But it says "Element adaptive-icon must be declared". Target SDK and build tools are both set to 26.

It builds successfully, but I don't have any device to test it, so my question is - does it works?

P.S.: Foreground is valid VectorDrawable

like image 804
Dima Rostopira Avatar asked Jul 31 '17 09:07

Dima Rostopira


2 Answers

I recommend you to create a Android O virtual device from Android Studio Virtual Device Manager for testing adaptive icons. I am also getting same error in Android Studio 2.3.3. Seems like Android Studio 2.3.3 does not support adaptive icon tag. We need to get Android Studio 3.0 for that.

Even docs for Adaptive Icons in Android developer website shows Android Studio 3.0 screenshots

https://developer.android.com/preview/features/adaptive-icons.html

Edit:- I have checked and found out that Adaptive Icon is working fine in app build from Android Studio 2.3.3 irrespective of "Element adaptive-icon must be declared" error.

like image 165
Shubhendra Singh Avatar answered Oct 29 '22 11:10

Shubhendra Singh


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>
like image 45
Biki Avatar answered Oct 29 '22 09:10

Biki