Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot resolve symbol @drawable/ic_launcher [duplicate]

Tags:

android

I have an ImageView in my layout, see below code. When I'm trying to set the src attribute to be my launcher icon, I get the following error:

Cannot resolve symbol '@drawable/ic_launcher'

ic_launcer.png is added to my drawables folder, see below image. Why can I not reference my image in my ImageView?

Project structure:

Project structure

Layout.xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <LinearLayout
        android:layout_weight="1"
        android:orientation="horizontal"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <ImageView
            android:src="@drawable/ic_launcher"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />

        <LinearLayout
            android:orientation="vertical"
            android:layout_width="match_parent"
            android:layout_height="match_parent">

            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content" />

            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content" />
        </LinearLayout>
    </LinearLayout>
</LinearLayout>
like image 207
Marcus Avatar asked Mar 24 '15 21:03

Marcus


2 Answers

Change(you have no drawable folders):

@drawable/ic_launcher

To(you are using mipmap folders):

@mipmap/ic_launcher

mipmaps - used for icons only - mipmap vs drawable folders

drawables - used for images other than icons

According to this Google blogpost:

It’s best practice to place your app icons in mipmap- folders (not the drawable- folders) because they are used at resolutions different from the device’s current density.

like image 51
Jared Burrows Avatar answered Nov 09 '22 21:11

Jared Burrows


your drawable are inside mipmap, which should be used to app-launcher. If you want to use it as drawable you should copy those inside one of the drawable/ folders

like image 34
Blackbelt Avatar answered Nov 09 '22 21:11

Blackbelt