24

We have a large Xamarin.Android project with two depending projects and a bunch of third party dll's. Doing a debug deployment (without any changes) onto a Hax-x86 Emulator or a Nexus 5 device is painfully slow (> 80 seconds). For comparison the Xamarin.iOS version of the App deploys in under seven seconds onto a real device.

To test the deployment times I've also created a fresh Xamarin.Android project which deploys in about four seconds. When I add a depending project, the deploy time goes up to seven seconds. When I add a layout file to the depending project the deployment time increases to about ten seconds.

Is it possible to speed the Android build and deployment up with Xamarin Studio? A big Eclipse Android Projects is deployed rather quick in comparison.

Update:

Just running the installation build step takes about 40 seconds:

time xbuild /t:Install BigApp.csproj
...
...
...
Time Elapsed 00:00:42.8526970

about half the time is spend where the above command prints to console:

Target _CompileDex:
      JavaSourceFiles:
      JavaLibraries:
      ExternalJavaLibraries:
Tool /usr//bin/java execution started with arguments: -Xmx512M -jar 
/Users/myname/Library/Developer/Xamarin/android-sdk-mac_x86/build-tools/17.0.0//lib/dx.jar 
--no-strict --dex --output=obj/Debug/android/bin/classes.dex obj/Debug/android/bin/classes
/Library/Frameworks/Xamarin.Android.framework/Versions/Current/lib/mandroid/platforms/android-15/mono.android.jar
/Users/myname/Projects/BigApp/obj/Debug/__library_projects__/TestFlightBindings.Jars.TestFlightLib_1_2.jar
/Users/myname/Projects/BigApp/obj/Debug/__library_projects__/android-support-v4.jar
/Users/myname/Projects/BigApp/obj/Debug/__library_projects__/classes.jar
/Users/myname/Library/Developer/Xamarin/android-sdk-mac_x86/extras/google/google_play_services/libproject/google-play-services_lib/libs/google-play-services.jar

When I run the solution from Xamarin Studio this step happens twice. Once for the depending project and once for the main project. I tried to reproduce this behavior on the console with

"/Applications/Xamarin Studio.app/Contents/MacOS/mdtool" -v build "--configuration:Debug -t Install" "BigApp.sln"

but that only builds the main project.

Update:

I created a small demo project with very slow deployment time: https://github.com/perpetual-mobile/SlowAndroidDeploymentWithXamarin

Rodja
  • 7,998
  • 8
  • 48
  • 55
  • Try to use shared runtime. I.e. not compile runtime into executable. – Maxim Korobov Nov 23 '13 at 11:39
  • I am using the shared runtime. You can easily reproduce the slow behavior yourself by just creating a fresh project, adding and some layout files or a dependent library project. – Rodja Nov 24 '13 at 10:56
  • 1
    The Xamarin Team has created a Bug for this issue: https://bugzilla.xamarin.com/show_bug.cgi?id=16622 – Rodja Dec 06 '13 at 08:15
  • Did anyone ever find a workable solution? October 2018 and I'm waiting 2~3 minutes to see code changes on the screen. This is on both emulators and real devices. – Noobie3001 Oct 12 '18 at 14:31

1 Answers1

7

I contacted the Xamarin guys about this problem and they fixed two issues in Xamarin.Android:

The build time for my huge project without any changes is now ~5 seconds. And when making a code change in the deepest depending lib a deploy cycle does not take longer than 16 seconds.

Rodja
  • 7,998
  • 8
  • 48
  • 55
  • I posted my case on Xamarin forum https://forums.xamarin.com/discussion/82287/xamarin-android-reduce-time-of-compilation-dalvik-ressources-aapt/p1?new=1 did you make something to have faster build? – Jerome2606 Nov 10 '16 at 15:43
  • 7
    I have now Xamarin for Android v 7.0 and it is very slow building –  Jan 06 '17 at 18:10