Gradle build is not successful because it cannot find ic_launcher_foreground.xml in drawable.

- 525
- 2
- 8
- 17
-
2are you able to physically locate the file? If yes then clean and rebuild your project – Sara Tirmizi Mar 22 '18 at 04:36
-
No. I can't find the file – Thrinadh Reddy Mar 22 '18 at 04:38
-
1that means ic_launcher_foreground doesn't exists in the folder , resources only available in your res drawable folder will be allowed to use here – Sara Tirmizi Mar 22 '18 at 04:40
-
1@ThrinadhReddy if you can't find the file physically then it won't be there and error is valid :) – Umair Mar 22 '18 at 04:41
-
3@ThrinadhReddy - how did you ever resolve this? I too am having the same problem. I select a PNG file as my foreground asset type:image, and when its done its NOT generating a `ic_launcher_foreground.xml` file. Without it my project build is failing because both the `ic_launcher.xml` and the `ic_launcher_round.xml` file reference the `ic_launcher_foreground.xml` file. This is driving me NUTS. If I select asset type: color, text or clip art - the tool will generate `ic_launcher_foreground.xml` file, but not if a PNG file is selected. HELP! – rolinger Apr 19 '20 at 00:52
-
I'm using react-native. I want to create app icon via android studio. Why did I add a new image asset, but it deleted the 2 files `ic_launcher` and `ic_launcher_round`, only the `ic_launcher_foreground` file was gone. I added the new asset again, it has the other 2 files, but the ic_launcher_foreground file is deleted. At this time, I can't run the project anymore, it says error: `resource mipmap/ic_launcher_foreground not found`. The best I can do is delete all the mipmap folders, then add new image asset again, there will be all 3 files. Why? I see instructors, they create all 3 files. – Nam Lee Aug 31 '22 at 19:07
15 Answers
I had the problem and the file did exist.
I went into the file and formatted the contents (aka made a change), and that fixed the build system recognising the file.

- 75,855
- 30
- 208
- 233
-
1I had exactly this same problem.. weird is that the build system would not pick the file if I didn't manually change the .xml... – João Rebelo Apr 10 '20 at 21:39
-
14After banging my head against the wall for 30 mins, and recreating the assets multiple times, **this** is what solved it for me. Opened the 'existing' foreground xml, pressed enter at end of tag, and rebuilt. And it's working now. Loco!! – Adi B May 05 '20 at 18:34
-
-
-
My solution: ic_launcher_foreground.xml file was simply missing a "" header line. After adding that it all worked well! Hope it helps! :) – SndrSchnklshk Jan 31 '23 at 05:36
-
@SndrSchnklshk I don't think header is required, but touching the file definitely helps. – Miha Markic Feb 20 '23 at 16:03
-
@Miha Haha. I like that. I wish that solved all my 'issues'. Haven't tried; but simply formatting + saving the file is good as well? – SndrSchnklshk Feb 21 '23 at 02:43
-
I solved it by deleting the project's Mipmap folders and creating the icon again by right clicking on the res / folder

- 441
- 4
- 3
-
6Worked for me. Although the instructions could be clearer: After clicking right click on the res folder > New > Image asset – Herii Sep 12 '21 at 05:03
If at all you delete the ic_launcher_foreground.xml
or ic_launcher_background.xml
files from your android project then no need to worry.
Simply,
- right click the drawable directory (inside res folder) and select New ---> Image Asset. (2 above named files will automatically be generated with the ic_laucher)
- then click next and finally finish.

- 36,322
- 27
- 84
- 93

- 141
- 1
- 2
-
2I am attempting to do this and for some reason the `image asset` tool is not creating the `ic_launcher_foreground.xml` file - everything else looks to be in place. I used an actual image to create my icons - and selected the path to that image in the `foreground` tab `Asset Type Path`. When I click `next` is shows me all the output directories/files to be created - the `ic_launcher_foreground.xml` file is not listed anywhere, only `drawable/ic_launcher_background.xml`, `mipmap-anydpi-v26/ic_launcher.xml` and `mipmap-anydpi-v26/ic_launcher_round.xml` – rolinger Apr 18 '20 at 13:28
-
I did the same and have the `ic_launcher_foreground` image but then lost files `ic_launcher` and `ic_launcher_round` – Nam Lee Aug 31 '22 at 08:24
It is because you have accidentally deleted ic_launcher_forground
or it is missing due to some reason
Its genererally present in your drawable folder
A quick fix is you can add this file and rebuild your project again ic_launcher_forground

- 1,464
- 9
- 20
-
3Thank you for downvote a comment with brief explanation would be really helpful... – Akshay Katariya Mar 22 '18 at 04:45
I had the same problem too and I solved it by:
- Make a new project or open an existing one
- Copy the XML file
ic_launcher_foreground.xml
(v24) from that and paste it todrawable
.

- 3,466
- 3
- 22
- 33

- 31
- 4
-
1note that most of the described steps aren't required. The build is failing b/c the file is missing. To satisfy the requirements it's enough to create/copy any valid drawable (XML, JPG, PNG) give it name ic_launcher_foregroundand and place it in the drawables folder. Hope that helps. – fo2rist Sep 26 '19 at 16:15
I ran into this issue after updating my Launcher icon (using New and Image Asset). The issue was resolved by, simply, updating my Launcher icon a second time. No idea why this wasn’t done properly the first time.

- 1,934
- 1
- 25
- 41
-
1This worked for me each time. I am complete novice, usually iOS, so thanks! – aaronsti Mar 26 '22 at 02:16
I had the same problem. I checked the contents of drawable
folder. Found out that the drawable-v24
folder was empty.
To solve this issue, right click on res
and open in explorer/finder/files (based on what OS you use) and copy the contents of drawable
to drawable-v24
.
Find the folders in the path in the picture in this link:
In Android Studio, open res
-> mipmap
Open ic_launcher
folder and it contains drawable as per folder wise (hdpi, mdpi, xhdpi, xxhdpi etc).
Now in any folder, let hdpi folder, delete
the unrequired file with the same name but a different extension
(Usually we need to delete ic_launcher_round.webp file).
Repeat it for ic_launcher_foreground
and ic_launcher_round
folder also.
Then again create your launcher icon (app
folder -> Right Click -> New -> Image Asset).

- 241
- 3
- 4
-
1can you please explain this solution with some more details it works for me but would like to know more. – Ajay Pandya May 13 '22 at 07:15
-
This is not good Approach! We can import the VectorFile and all of this will automatically happens during import. Do not forget to `clean build` after this. – sud007 Jun 27 '23 at 04:36
For some reason when I added a file it made the default drawables not findable. Even after gradle sync and build. Then when I deleted the file I had added, suddenly the drawables were findable again and the build went through. Now I still have to figure out how to fix my original issue...

- 1,878
- 2
- 23
- 43
Just delete files/folders inside the mipmap folders (not the mipmap folder) and create the icon again by right-clicking on the mipmap folder. In my case, this issue was solved this way.

- 527
- 2
- 5
- 13
- Close Android Studio
- & open again then again set your project icon
- again using App -> new -> Image assert
- after that choose icon again
- and click next next -> finish after that build project
it will work for you
if not work then again set the icon without restarting android studio

- 6,326
- 1
- 39
- 37
When creating the image asset be careful to the directory path
if you select debug
you will find an issue when creating your release

- 2,540
- 1
- 28
- 40
I'm new to Android and the ic_launcher_foreground
did exist but what I didn't realize is that when I created a new class that needed access to ic_launcher_foreground
, I had to import the R
class as explained here
I only had to add this to the top of my class:
import com.your.package.R
For other newbies like me, you can get com.your.package
from the very top of MainActivity

- 17,576
- 18
- 108
- 256
I'm facing the same problem. This happens most often when importing icons in SVG format.
The formatting of the icon code when exporting it from an external resource (for example, figma) differs from the format that is required.
The solution to the problem is quite simple - go to the XML file of the icon and autoformat the code using the keyboard shortcut CTRL + ALT + L

- 3
- 2