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.
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.
I created a small demo project with very slow deployment time:
I contacted the Xamarin guys about this problem and they fixed two issues in Xamarin.Android:
- https://bugzilla.xamarin.com/show_bug.cgi?id=16622 (provided since Xamarin Android 4.12.0)
- https://bugzilla.xamarin.com/show_bug.cgi?id=15162 (provided since Xamarin Android 4.10.0)
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.