Xamarin Forms Android build hangs for 10 minutes

Apk07Apk07 Member ✭✭

I am having trouble building my Xamarin Forms project in Visual Studio. It takes 10 minutes or longer to build the Android project, even with a simple 1-line code/XAML change. I have scoured the web, MSDN, Visual Studio’s forums, StackOverflow, and here trying to find solutions to the problem. The PCL builds in ~3 seconds, I am not currently building the iOS one, and then the Android one just takes aaaaaaaaaages. It doesn't matter if its in debug mode or release mode, it is totally unworkable due to how long it takes to build.

  • I have tried to upgrade and downgraded numerous Nuget packages for Xamarin and others (tried XF 4.0.0+, tried going back to 3.x, etc)
  • I have tried to switch targeted Android versions from 9.0 to 8.1
  • I have tried to switch the minimum Android Version from 5.0 up to 6.0
  • I have tried building on both VS 2017, VS 2019, and the latest preview release of VS 2019. Same issue on them all.
  • I have tried running VS as Administrator
  • I have tried toggling every single configuration setting in Android Manifest and elsewhere
  • I have tried uninstalling Hyper-V and Hypervisor (at a forum thread's suggestion)
  • I have updated Windows 10 to the newest version
  • I have submitted a bug report in VS with build logs and I haven't received any useful response yet
  • I've deleted the BIN and OBJ folders a hundred times
  • I've tried downgrading NETStandard from 2.0.3 to 2.0.0 and 2.0.1 (another random forum suggestion)

This worked a couple weeks ago when I last tried this project. I’m not sure whats changed. I used to be able to rapidly build/clean/debug without issue. I'm at my wit's end trying to figure out why this takes so long for a fairly small project.

Best Answer

Answers

  • yousufctecyousufctec USMember ✭✭✭
    edited June 3

    Hi @Apk07 ,
    Can I check with you whether do you use an AMD processor and trying to build to an emulator? If so, it does take ages, it's better to try to debug or deploy directly to an android device, it is much faster there and I'm doing the same. Because, Intel processors got Intel HAXM hardware acceleration which makes them much faster in using emulators and they have a very continued effort to keep it going on a promising level.

    But for AMD, alternatively you can check here to setup parameters that will help you increase your performance on AMD processors, if you still don't prefer android device.

    This comment is considered you using AMD processor, awaiting your response on it.

    Regards,
    Yousuf.

  • Apk07Apk07 Member ✭✭

    @yousufctec

    I am on Intel with HAXM, and have tried on multiple PCs and multiple different versions of Visual Studio. It makes me think it may be an issue with the solution/project and not the specific computer.

    I'm not just experiencing this when debugging to an emulator, but even when just right-clicking the Android project and selecting "Build". It is the build process that is hanging and consuming so much time, so it doesn't matter if it is being debugged, deployed, or even archived. It also doesn't matter if its in debug or release mode. The PCL project on the other hand builds instantly...

    It is very bizarre as it worked great the last time I accessed the project (2 or 3 weeks ago) and its really ruining any effort to try and develop my app. I wish I could just zip-up the solution and post it here for someone to poke around in, but there's too much in it that I'm not able to share.

  • JarvanJarvan Member, Xamarin Team Xamurai

    Check the nuget packages's state in References. Maybe the problem is caused by redownloading the packages.

    You can refer to: https://stackoverflow.com/questions/42770130/visual-studio-xamarin-hanging-on-every-build-clean-or-rebuild-with-aapt-exe

  • Apk07Apk07 Member ✭✭

    @yelinzh said:
    Check the nuget packages's state in References. Maybe the problem is caused by redownloading the packages.

    You can refer to: https://stackoverflow.com/questions/42770130/visual-studio-xamarin-hanging-on-every-build-clean-or-rebuild-with-aapt-exe

    Unfortunately doesn't seem to be the issue either... I don't see any yellow triangles on my nuget packages. I went ahead and ran "reinstall" on all the projects anyway but it didn't resolve the issue.

    Is there anything else I can provide to help diagnose my solution's issue?

    I downloaded a sample project from here: https://developer.xamarin.com/samples/xamarin-forms/Todo/
    and this sample builds in ~28 seconds from scratch

  • Apk07Apk07 Member ✭✭

    Copying my code into a completely new solutions seems to have solved the problem. Absolutely bizarre issue and I don't know what caused it, but its fixed now. Build times are down to ~30 seconds.

Sign In or Register to comment.