drawable/ic_launcher_foreground not found. How to find that xml file

23,743

Solution 1

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.

Solution 2

I solved it by deleting the project's Mipmap folders and creating the icon again by right clicking on the res / folder

Solution 3

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,

  1. 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)
  2. then click next and finally finish.

Solution 4

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
enter image description here

A quick fix is you can add this file and rebuild your project again ic_launcher_forground

Solution 5

I had the same problem too and I solved it by:

  1. Make a new project or open an existing one
  2. Copy the XML file ic_launcher_foreground.xml (v24) from that and paste it to drawable.
Share:
23,743
Thrinadh Reddy
Author by

Thrinadh Reddy

Updated on July 09, 2022

Comments

  • Thrinadh Reddy
    Thrinadh Reddy almost 2 years

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

    Here are the error messages

    Actual error occured in this file

  • Akshay Katariya
    Akshay Katariya about 6 years
    Thank you for downvote a comment with brief explanation would be really helpful...
  • fo2rist
    fo2rist over 4 years
    note 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.
  • João Rebelo
    João Rebelo about 4 years
    I had exactly this same problem.. weird is that the build system would not pick the file if I didn't manually change the .xml...
  • rolinger
    rolinger about 4 years
    I 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
  • Adi B
    Adi B almost 4 years
    After 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!!
  • Herii
    Herii over 2 years
    Worked for me. Although the instructions could be clearer: After clicking right click on the res folder > New > Image asset
  • paakjis
    paakjis over 2 years
    yep, that worked.
  • Pascal
    Pascal over 2 years
    jup that helped ... there must be a dump cache somewhere
  • aaronsti
    aaronsti about 2 years
    This worked for me each time. I am complete novice, usually iOS, so thanks!