Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android studio does not find drawable icon

I am trying to develop in android-studio on MAC and I am coming across a weird problem. Within the activity code I can not refer to an image which lies in the mipmap folder. In particular I am have created a notification as:

...

Notification notify = new NotificationCompat.Builder(this)
    .setContentTitle(title)
    .setContentText(body)
    .setSmallIcon(R.drawable.ic_launcher)
    .setContentIntent(startPendingIntent)
    .build();

...

and I receive the error "cannot resolve symbol ic_launcher". Strange is also the problem, that I can not copy-paste the icons into the drawable folder which is empty. Where and how should I place the icons in order to visible within the code in android studio?

like image 988
arjacsoh Avatar asked Mar 13 '15 11:03

arjacsoh


People also ask

How do I import a drawable file?

Drag and drop your images directly onto the Resource Manager window in Android Studio. Alternatively, you can click the plus icon (+), choose Import Drawables, as shown in figure 3, and then select the files and folders that you want to import. Figure 3: Select Import Drawables from the dropdown menu.

What is Android drawable folder?

A drawable resource is a general concept for a graphic that can be drawn to the screen and which you can retrieve with APIs such as getDrawable(int) or apply to another XML resource with attributes such as android:drawable and android:icon . There are several different types of drawables: Bitmap File.


2 Answers

You need to access the drawable using R.mipmap.ic_launcher

like image 73
freddieptf Avatar answered Nov 04 '22 09:11

freddieptf


Close Android Studio, then open up finder. Go to the project directory. Go navigate to your project's mipmap folder. Copy the images, then go to the drawable folder and paste the images in their respective resolution folders. Open up android studio again and they should be in the drawable folder.

like image 39
Bobby Avatar answered Nov 04 '22 09:11

Bobby