13

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

4

2 回答 2

11

我建议你从 Android Studio Virtual Device Manager 创建一个 Android O 虚拟设备来测试自适应图标。我在 Android Studio 2.3.3 中也遇到了同样的错误。好像 Android Studio 2.3.3 不支持自适应图标标签。为此,我们需要获得 Android Studio 3.0。

甚至 Android 开发者网站中的 Adaptive Icons 文档也显示了 Android Studio 3.0 截图

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

编辑:-我检查并发现自适应图标在 Android Studio 2.3.3 的应用程序构建中工作正常,无论“必须声明元素自适应图标”错误。

于 2017-08-04T11:04:23.380 回答
1

ic_launcher.xml 应该是这样的

 <?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>
于 2017-10-24T12:52:10.153 回答