Adding png to Resources\Drawable hangs Visual Studio RRS feed

  • Question

  • User80492 posted

    Every time I add a png to Visual Studio in our Xamarin.Forms Android project, Visual Studio hangs. Not sure what is causing it, but I didn't have the same issue when adding the first image to the project. I can add images no problem in non-Xamarin apps and also do not have a problem adding it to the share library UI project.

    Wednesday, October 22, 2014 2:06 AM

All replies

  • User80492 posted

    Nevermind. If I deleted the image from the project file system under Resources\Drawable, then tried to add it again it doesn't hang. It only seems to hang when it is already in the project file system and I choose to overwrite it.

    Wednesday, October 22, 2014 2:08 AM
  • User73862 posted

    Hmm, for me it hangs all the time. It doesn't matter if it is a new image or overwriting an old one. It worked until last week, but something happened and now it hangs all the time. I'm trying to add it to drawable-*dpi.

    LE: After finding this , I can also confirm that updating the Android SDK fixes this.

    Thursday, October 23, 2014 8:04 AM
  • User80492 posted

    I've been having to add it to the main project folder then drag it to drawable.

    Thursday, October 23, 2014 1:09 PM
  • User40312 posted

    Have been experiencing the same problem for a few days, ending up here, updating SDK now... :)

    Friday, January 23, 2015 4:35 PM
  • User65389 posted

    This annoyng bug still (or again) exits in 3.11.576. I have added a .png to my android project (\Resources\Drawable) and then had to shut down VS (and lost my last changes) :angry:

    Tuesday, June 2, 2015 1:27 PM
  • User65389 posted

    And.. it's worse... the .png don't was included in the project (and also not showed on the page).
    I now have "included" it in the project... and.. VS hangs once again..!

    Tuesday, June 2, 2015 1:58 PM
  • User65389 posted

    Shut down VS once again, restart VS and once again included the .png in the project...
    Now it seems to work (after two times restart VS and lost of my latest changes). :neutral:

    Tuesday, June 2, 2015 2:03 PM
  • User16414 posted

    This bug is happening again for me. (https://bugzilla.xamarin.com/show_bug.cgi?id=18452) All versions are in the attached image, Xam 3.11.590, Xam.Android being the most important. Only started happening after updating yesterday (09.06.2015). Definitely was not a problem before that. I've had to kill VS every time I try to add new .png, regardless of how I try to add it. Not urgent to fix I guess since the workaround is to use Xam Studio and add through there...bit of a pain to jump out of VS every time though :-/ I run VS as Administrator...don't know if that matters...

    Tuesday, June 9, 2015 2:06 PM
  • User51906 posted

    @MarkWallis @FredyWenger This is a Xamarin.VS bug not Forms ;) I'm experiencing this from time to time too. The easiest workaround is to add the .png files directly to the .csproj project files. I'm using Notepad++ for that. You can do that while VS is open. When you saved your changes in Notepad++ it asks to reload the projects and then they are added.

    Tuesday, June 9, 2015 2:39 PM
  • User65389 posted

    I know, that's a Xamarin.VS-bug (I don't have opened this thread here in the .Forms-Forum - only posted a message including the version to the VS-Integration-SW-Version :tongue:)
    But thanks for the hint (I will try it out, the next time, I have to add an image to the Android-Project) :smile:

    Tuesday, June 9, 2015 2:46 PM
  • User84418 posted

    I was just copying some images to the resources folder and was browsing the forum waiting for visual studio to catch up. Then I seen this thread. Yep, Visual Studio has crashed. I guess I have this problem too. Funny coincidence though.

    Tuesday, June 9, 2015 2:48 PM
  • User107505 posted

    Of course I have the same bug. The only way to solve this problem now is to add the .png file .csproj project files using Notepad++

    Tuesday, June 9, 2015 3:05 PM
  • User84418 posted

    I got it working by doing it through Xamarin Studio as @MarkWallis suggested.

    Tuesday, June 9, 2015 3:16 PM
  • User103333 posted

    I was doing what @RaphaelSchindler did, it works, but is a headache.

    Tuesday, June 9, 2015 4:49 PM
  • User65389 posted

    @AEON, @Teo, @MennoMorsink.5503, @MarkWallis, @RaphaelSchindler, @David.Welsh, @Marco.8016, @MiguelCervantes and at all other readers of this thread. Thanks the hint of Raphael, I was able to investigate the problem in detail and - I think - have find out the bug(s) in the integration-SW. You can find all details in the attached .pdf I also will post in the VS-Formum and fill a bug in bugzilla

    Cheers :smile:

    Wednesday, June 10, 2015 10:36 AM
  • User51906 posted

    @FredyWenger I have some additions and corrections to your pdf ;)

        Instead do it manually:
        Close VS <-- This is not necessary. I always changed the .csproj file while VS is open.
        This has worked in earlier versions (must be a new bug in some newer versions). <-- I'm experiencing this since the beginning of this year from time to time.

    Really good work :)

    Wednesday, June 10, 2015 10:47 AM
  • User65389 posted

    @RaphaelSchindler: Thanks - I only was able to investigate it thanks your base-hint :blush:
    Close VS: As I don't know, what exactly VS cashes to the .csproj-File (in the variouuus "hidden" directories), I close it to be sure :wink: In the meantime, I have added a messaging in the VS-thread:
    http://forums.xamarin.com/discussion/42670/stable-service-release-xamarinvs-3-11-586-bug-fixes-for-3-11-445#latest and also have filled the bug: https://bugzilla.xamarin.com/show_bug.cgi?id=30968

    I finally hope that my (once again invested) few hours give us a (much) more stable IS soon :wink:

    Wednesday, June 10, 2015 10:59 AM
  • User51906 posted

    I think this is some sort of blocking folders while try writing to one or writing to the .csproj file and it is somehow blocked from VS in another thread. I had some silly behaviour like that with PCL's that I changed.

    Wednesday, June 10, 2015 11:02 AM
  • User103333 posted

    @FredyWenger nice job dude! Thank you!

    Wednesday, June 10, 2015 7:54 PM
  • User65389 posted

    @MiguelCervantes: Thanks :smile:

    Wednesday, June 10, 2015 8:12 PM
  • User80438 posted

    Same problem here. I've now come to the conclusion that Xamarin is a product that none of us should be paying for.

    Saturday, June 27, 2015 2:50 PM
  • User75163 posted

    Same problem here

    Wednesday, July 1, 2015 10:51 PM
  • User76049 posted


    Have you upgraded to the scary sounding .666 build (stable)? it should/could/possibly sort the VS studio hanging issues.


    Wednesday, July 1, 2015 10:59 PM
  • User75163 posted

    @NMackay yep I have. I think the issue is actually reintroduced in this release...

    Wednesday, July 1, 2015 11:07 PM
  • User76049 posted


    That would be very ^&%. I'll have to test that tomorrow, something to look forward too :neutral:

    Wednesday, July 1, 2015 11:14 PM
  • User118354 posted

    I have upgraded, and it did fix our long-standing issue of not being able to add resources to Droid projects. Our temp fix was to close VS, open the project in XS, and add resources there, then go back to VS.

    Thursday, July 2, 2015 7:32 AM
  • User76049 posted

    I did test and it works fine in VS2013 (Update4) with build 666.

    Thursday, July 2, 2015 8:12 AM
  • User122934 posted

    For me, while Visual Studio is hanging up, killing the Java task seems to bring everything back for me. I have not tried messing with PNGs since the update mentioned above though.

    Monday, July 13, 2015 8:37 PM
  • User92384 posted

    run taskmgr, in Task Manager find monodroid.exe, if it is there kill it, somehow fix my problem.

    Monday, July 13, 2015 8:59 PM
  • User107708 posted

    I am facing the same issue , while adding images into Resources\Drawable folder, visual studio hangs. I updated Visual Studio and Android SDK Tool. But it doesn't seems to be solving the issue.

    Visual Studio Ultimate 2013 - Ver 12.0.31101.00 - Update 4. Android SDK Tools - 24.3.3

    How can solve this issue??????

    Thursday, July 16, 2015 10:03 AM
  • User65389 posted

    Have you seen my posting from June 10 (above)...?
    I have investigated the problem and found, that's a bug. In the attached .pdf you can see all the details and also how to do it manually I further have filled a bug (link see second message to June 10). It seems (confusing duplicate bugs in BugZilla) as the bug has the state "Confirmed" (but isn't solved yet).

    So I suggest you to do it manually (according my posted .pdf).

    Hope this helps...

    Thursday, July 16, 2015 10:26 AM
  • User76049 posted

    This did reoccur for me in a project I'd been working on pre the last stable Xamarin build.

    After killing devenv.exe in taskman I reopened the project and selected "show all files" and then included the file into the project. After that it seemed okay and allowed adding drawables etc.

    Thursday, July 16, 2015 10:56 AM
  • User13824 posted
    • One known cause of this problem is when the Android SDK and the Xamarin versions are mismatched. For example, XamarinVS 3.11.666 with Android SDK Tools 24.2 will hit this problem. Upgrading to Android SDK Tools 24.3 will solve that particular cause of the problem.

      I have filed a bug to request that this kind of version mismatch should produce an error message rather than hanging the IDE.

    • There have also been reports of very similar symptoms that are not caused by the version mismatch issue. In particular, 2 of the reports on Bug 31667 (as well as NMackay's post in this thread earlier today) suggest that this issue can happen during the first attempt to add an image to the resources folder of a particular project. In those reports, force-quitting Visual Studio, reloading the project, and then re-adding the image seemed to help (at least on some attempts).

    • As mentioned in Raphael's, Fredy's, and Marco's posts earlier in the thread, one way to sidestep the issue entirely would be to edit the <AndroidResource> elements by hand in the the text of the .csproj rather than using the Solution Explorer.

    Thursday, July 16, 2015 9:58 PM
  • User23807 posted

    Indeed, I was using SDK-Tools 24.2.

    Saturday, July 18, 2015 11:22 PM
  • User73207 posted

    I'm experiencing this too!

    Wednesday, August 12, 2015 7:46 PM
  • User55225 posted

    @2BitNerd This worked for me.

    From Brendan Zagaeski's post above •One known cause of this problem is when the Android SDK and the Xamarin versions are mismatched. For example, XamarinVS 3.11.666 with Android SDK Tools 24.2 will hit this problem. Upgrading to Android SDK Tools 24.3 will solve that particular cause of the problem.

    Thursday, August 13, 2015 12:37 AM
  • User62222 posted

    I've become accustomed to having VS crash on adding an android image asset, and eventually I give in an edit the csproj file by hand.

    If there are lots of assets to add I might use Xamarin Studio, then copy out the xml from the csproj file, undo the other changes Xamarin Studio made to the Android project (and iOS project for some reason, which it always does just by opening the solution), then paste in the copied xml into the csproj file to get the assets into the solution. (We've had Xamarin Studio wreck things just by having opened the solution with it in the past, so we pretty much avoid using it on our production apps).

    Today I'm running Android SDK Tools 24.3.4, with Xamarin.Android, Xamarin 3.11.837.0, Visual Studio 2015 14.0.23107.0 D14REL, .Net 4.6.00079, wait I'll just copy the version guff from Studio in case that gets something useful too. (Android has API 23 too, just noticed its not listed below so guess Xamarin isn't supporting it yet)

    === Xamarin Studio ===

    Version 5.9.5 (build 10) Installation UUID: a2f093b8-9e70-42ef-96b3-d19235a7d8cc Runtime: Microsoft .NET 4.0.30319.42000 GTK+ 2.24.22 (MS-Windows theme) GTK# 2.12.26

    === Xamarin.Android ===

    Version: 5.1.5 (Business Edition) Android SDK: C:\Android\sdk Supported Android versions: 2.3 (API level 10) 4.0.3 (API level 15) 4.1 (API level 16) 4.2 (API level 17) 4.3 (API level 18) 4.4 (API level 19) 4.4.87 (API level 20) 5.0 (API level 21) 5.1 (API level 22) Java SDK: C:\Program Files\Java\jdk1.8.051 java version "1.8.051" Java(TM) SE Runtime Environment (build 1.8.0_51-b16) Java HotSpot(TM) 64-Bit Server VM (build 25.51-b03, mixed mode)

    === Xamarin Android Player ===

    Not Installed

    === Build Information ===

    Release ID: 509050010 Git revision: 48d16bc4f12ce3938964fc7c3d72fdc6887ad4ad Build date: 2015-08-18 16:53:58-04 Xamarin addins: c2d51b360ad9f59e689046d47030df27de28f94a

    === Operating System ===

    Windows 6.2.9200.0 (64-bit)

    Thursday, August 20, 2015 11:02 PM
  • User47538 posted

    hummm... Apparently the bug is present again... I don't know in the past... but now I am having this same problem... I am using VS 2015 Enterprise, version 14.0.23107.0 D14REL and XS 5.9.5 Build 10, Xamarin Android 5.1.5. OS Windows 10, 6.2.9200.0 (64 bits)

    Thursday, September 3, 2015 10:31 PM
  • User122934 posted

    @StevenLewis I can confirm that Allister's workaround of adding the image directly to the .csproj file works great for me. Just find entries for other images you have already added in there and copy/paste the entries. I always close the solution before editing the file but I am not sure if that is necessary or not.

    Thursday, September 3, 2015 11:00 PM
  • User47538 posted

    @hvaughan Yes, it Works... also opening the Project in Xamarin Studio and adding the image there, then reopen it using Visual Studio.

    Thanks for the reply!

    Thursday, September 10, 2015 5:33 PM
  • User129770 posted

    I can't believe this is still not fixed. Thank you @FredyWenger for the pdf.

    Here's the quick fix step by step for noobs like me:

    1. Add the image using file explorer to YourProject.Droid\Resources\drawable\
    2. Open the YourProject.Droid.csproj file with a text editor.
    3. Find the line with "icon.png"
    4. Add this below that line: <AndroidResource Include="Resources\drawable\yourImage.png" />

    I keep Visual Studio open while doing these. When I return to VS, I click Reload on the pop-up and the image appears.

    Thursday, October 1, 2015 10:37 PM
  • User65389 posted


    Thanks for your comment - you're welcome :smile:

    Friday, October 2, 2015 9:10 AM
  • User165797 posted

    copy all the images of drawable folder and delete that folder ....now create drawble folder again ...this help me now a days

    Tuesday, October 13, 2015 6:16 AM
  • User228663 posted

    @ErhanAlankus Thanks..

    Thursday, June 2, 2016 11:22 AM
  • User307736 posted

    Hi. Have same bug reproduced, it also does it with jpg files as well. Happens from time to time, have not found why yet, but i have a jpg file it does it 100% with, so i can email it to anyone interested in debugging this problem.

    Anyway I have found a way to avoid it, easier that editing cproj by hands. :)

    First of all if your project is already corrupted (crashes vs on opening it) - delete the image from the directory where you tried to add it, it's there and makes vs crash.

    Now just add problematic image files to the Portable project (i do it by drag'n'drop). Then drag from Portable project to Android project. Then Android eats it, profit.

    Tuesday, April 11, 2017 6:57 PM
  • User76049 posted


    I've been using the same workaround for the last two years

    • Paste the image/file into the directory of choice
    • Click on show/hide hidden files in the project explorer
    • Right click on the file and add to project
    Tuesday, April 11, 2017 7:07 PM
  • User307736 posted

    A quick note, with that workaround if i'm trying to rename the file already in Android resources i still got that crash.. Really they need to do something about it..

    Tuesday, April 11, 2017 7:16 PM
  • User76049 posted


    That doesn't happen for me, add TFS integration though and things get really *&^% though :neutral:

    Tuesday, April 11, 2017 7:18 PM
  • User307736 posted

    I have a feeling i found why this crash is happening please tell me if \im wrong.. When the image was download from internet and my windows 10 internally marks it as being from untrusted source, than here you go with that crash.. So an appearent workaround before adding file to project would be to right-click it in windows and select unblock in properties.

    Tuesday, April 11, 2017 7:55 PM
  • User76049 posted


    If you have a harsh group policy and not admin privileges maybe, certainly using Win10 for the last year I haven't experienced this but I've been in all admin groups and win10 caused so much issues (it was the only way they could me enough rights to develop).

    Anything Visual Studio/Xamarin related has to be run with full local admin.

    Tuesday, April 11, 2017 8:09 PM
  • User307736 posted

    I'm at full admin rights, doesn't help at all :)

    Tuesday, April 11, 2017 8:55 PM
  • User76049 posted

    Okay, tick tick tick.

    Ummm..... :) I'm out of ideas.

    Tuesday, April 11, 2017 9:02 PM