Reduce build time Xamarin.Android project

OSDMobileOSDMobile NLUniversity ✭✭
edited February 2018 in Xamarin.Android

Hi all,

Currently we encounter really long build times for our Android project.

Is this (see build log below) a normal build time for a Xamarin Android project with the following amount of assets?

  • 350 drawables
  • 210 Layout files
  • 65 values xml files

Do you have any suggestion to speed-up the build time? This is really annoying.

PS. we also have the problem that we need to do a clean build every time we change something in a xml file (for example when changing a color in a layout file).

Here is the build log when I do a clean DEBUG build for an Android emulator:

Done building project "MyApp.Droid.csproj".

Project Evaluation Performance Summary:
139 ms /Users/stefan/Projects/myapp/Core/CoreApp.Core.csproj 2 calls

Project Performance Summary:
70 ms /Users/stefan/Projects/myapp/Core/CoreApp.Core.csproj 4 calls
166920 ms /Users/stefan/Projects/myapp/Droid/CoreApp.Droid.csproj 1 calls

Target Performance Summary:
* ms GetCopyToOutputDirectoryItems 1 calls
0 ms PrepareResourceNames 1 calls
0 ms BeforeResGen 1 calls
0 ms AfterBuild 1 calls
0 ms RunCodeAnalysis 1 calls
0 ms _XamarinBuildAddDownloadedItems 1 calls
0 ms _XamarinBuildDownload 1 calls
0 ms SetWin32ManifestProperties 1 calls
0 ms RunXamarinPackageAnalysis 1 calls
0 ms BeforeResolveReferences 1 calls
0 ms GenerateManifests 1 calls
0 ms RunXamarinProjectAnalysis 1 calls
0 ms UpdateAndroidResources 1 calls
0 ms _XamarinBuildDownloadMasterTarget 1 calls
0 ms PrepareProjectReferences 1 calls
0 ms ResolveNativeReferences 1 calls
0 ms CreateCustomManifestResourceNames 1 calls
0 ms ResolveReferences 1 calls
0 ms GetFrameworkPaths 1 calls
0 ms ResGen 1 calls
0 ms CoreBuild 1 calls
0 ms PrepareForRun 1 calls
0 ms BeforeBuild 1 calls
0 ms CreateSatelliteAssemblies 1 calls
0 ms AfterResolveReferences 1 calls
0 ms Compile 1 calls
0 ms _CopySourceItemsToOutputDirectory 1 calls
0 ms _LinkAssemblies 1 calls
0 ms PrepareResources 1 calls
0 ms AfterResGen 1 calls
0 ms _ResolveMonoAndroidFramework 1 calls
0 ms UpdateAndroidAssets 1 calls
0 ms BeforeCompile 1 calls
0 ms GetTargetFrameworkProperties 1 calls
0 ms AfterCompile 1 calls
0 ms _UpdateAndroidResources 1 calls
0 ms _SetupDesignTimeBuildForBuild 1 calls
0 ms BuildOnlySettings 1 calls
0 ms BclBuildSetRunningFullBuild 1 calls
0 ms _SetupDesignTimeBuildForIntellisense 1 calls
0 ms _XamarinAndroidSupportVectorDrawableArgs 1 calls
0 ms ResolveSDKReferences 1 calls
0 ms _IncludeInstanceRunReference 1 calls
0 ms _ValidateLinkMode 1 calls
0 ms _CheckTargetFramework 1 calls
0 ms _RoslynPublicSignHack 1 calls
0 ms Build 1 calls
0 ms _EmitXamarinProjectAnalysisResults 1 calls
0 ms _CheckForContent 1 calls
0 ms _EmitXamarinPackageAnalysisResults 1 calls
0 ms ComputeIntermediateSatelliteAssemblies 1 calls
0 ms ExpandSDKReferences 1 calls
0 ms ProcessGoogleServicesJsonChecks 1 calls
0 ms _SetupInstantRun 1 calls
0 ms _SetupApplicationJavaClass 1 calls
0 ms BclBuildGetTargetPath 1 calls
0 ms _SeparateAppExtensionReferences 1 calls
0 ms _SetupDesignTimeBuildForCompile 1 calls
0 ms GetTargetPath 2 calls
0 ms _ReadPropertiesCache 1 calls
0 ms GetInstalledSDKLocations 1 calls
0 ms _SetTargetFrameworkMonikerAttribute 1 calls
0 ms GetNativeManifest 1 calls
0 ms _GetReferenceAssemblyPaths 1 calls
0 ms _CheckForDeletedResourceFile 1 calls
0 ms BclBuildAddProjectReferenceProperties 1 calls
0 ms _CheckForCompileOutputs 1 calls
0 ms _AddMultiDexDependencyJars 1 calls
0 ms _DefineBuildTargetAbis 1 calls
0 ms _CheckInstantRunCondition 1 calls
0 ms _GenerateSatelliteAssemblyInputs 1 calls
0 ms _CheckProjectItems 1 calls
0 ms _ValidateResourceCache 1 calls
0 ms VectorDrawableCheckBuildToolsVersionTask 1 calls
0 ms _CalculateAdditionalResourceCacheDirectories 1 calls
0 ms _SetEmbeddedWin32ManifestProperties 1 calls
1 ms _CreateAdditionalResourceCache 5 calls
1 ms _XbdRestoreItems_supportv4 1 calls
1 ms _XbdRestoreItems_transition 1 calls
1 ms _XbdRestoreItems_supportcoreui 1 calls
1 ms _XbdRestoreItems_supportcompat 1 calls
1 ms _CreatePackageWorkspace 1 calls
1 ms _XbdRestoreItems_supportannotations 1 calls
1 ms _XbdRestoreItems_supportfragment 1 calls
1 ms _XbdRestoreItems_firebaseanalytics 1 calls
1 ms _XbdRestoreItems_firebaseiid 1 calls
1 ms _XbdRestoreItems_recyclerviewv7 1 calls
1 ms _XbdRestoreItems_firebasecommon 1 calls
1 ms _XbdRestoreItems_playservicesmaps 1 calls
1 ms _XbdRestoreItems_firebaseanalyticsimpl 1 calls
1 ms _XbdRestoreItems_supportvectordrawable 1 calls
1 ms _XbdRestoreItems_supportmediacompat 1 calls
1 ms _XbdRestoreItems_playservicesanalytics 1 calls
1 ms _XbdRestoreItems_playservicesbase 1 calls
1 ms _XbdRestoreItems_playservicestasks 1 calls
1 ms _XbdRestoreItems_playservicesads 1 calls
1 ms _XbdRestoreItems_playservicesgass 1 calls
1 ms _XbdRestoreItems_supportcoreutils 1 calls
1 ms _XbdRestoreItems_playservicesanalyticsimpl 1 calls
1 ms _XbdRestoreItems_playservicesadslite 1 calls
1 ms _XbdRestoreItems_playservicestagmanagerv4impl 1 calls
1 ms _XbdRestoreItems_customtabs 1 calls
1 ms _XbdRestoreItems_playservicesgcm 1 calls
1 ms _XbdRestoreItems_playservicesbasement 1 calls
1 ms _XbdRestoreItems_playservicesclearcut 1 calls
1 ms _XbdRestoreItems_design 1 calls
1 ms _XbdRestoreItems_playservicesiid 1 calls
1 ms _XbdRestoreItems_cardviewv7 1 calls
1 ms _XbdRestoreItems_appcompatv7 1 calls
1 ms GenerateTargetFrameworkMonikerAttribute 1 calls
1 ms _SplitProjectReferencesByFileExistence 2 calls
1 ms _GenerateCompileInputs 1 calls
1 ms _GetAdditionalResourcesFromAssemblies 1 calls
1 ms _GetMonoPlatformJarPath 1 calls
1 ms _CheckForInvalidConfigurationAndPlatform 1 calls
1 ms _StripEmbeddedLibraries 1 calls
1 ms _CompileDex 1 calls
1 ms CoreResGen 1 calls
1 ms AssignProjectConfiguration 1 calls
1 ms _GetLibraryImports 1 calls
1 ms GetTargetPathWithTargetPlatformMoniker 2 calls
1 ms _XbdRestoreItems_animatedvectordrawable 1 calls
2 ms CheckAbiAndMinSDK 1 calls
2 ms _ExtractLibraryProjectImports 1 calls
2 ms _GetAddOnPlatformLibraries 1 calls
2 ms CreateManifestResourceNames 1 calls
2 ms SplitResourcesByCulture 1 calls
2 ms _ComputeAndroidAssetsPaths 1 calls
2 ms _CheckDuplicateJavaLibraries 1 calls
4 ms _ValidateAndroidPackageProperties 1 calls
4 ms GetReferenceAssemblyPaths 1 calls
4 ms _CreatePropertiesCache 1 calls
4 ms BclBuildValidateNugetPackageReferences 1 calls
5 ms _CreateIntermediateAssembliesDir 1 calls
5 ms _AddDebugStaticResources 1 calls
6 ms PrepareForBuild 1 calls
9 ms _XamarinAndroidBuildResourceRestore 1 calls
10 ms AssignTargetPaths 2 calls
11 ms _ResolveMonoAndroidSdks 1 calls
12 ms _WriteResolvedAssemblies 1 calls
13 ms _PrepareAssemblies 1 calls
13 ms BclBuildDetermineReferencesToRedirect 1 calls
14 ms _CopyConfigFiles 1 calls
16 ms _ConvertPdbFiles 1 calls
16 ms _GeneratePackageManagerJava 1 calls
20 ms _AddStaticResources 1 calls
26 ms _CollectConfigFiles 1 calls
30 ms _GetPrimaryCpuAbi 1 calls
35 ms _CollectPdbFiles 1 calls
36 ms _XamarinAndroidBuildAarRestore 1 calls
37 ms _CollectMdbFiles 1 calls
39 ms _DetermineJavaLibrariesToCompile 1 calls
42 ms CopyFilesToOutputDirectory 1 calls
67 ms _CollectMonoAndroidOutputs 1 calls
69 ms _GenerateCompileDependencyCache 1 calls
81 ms ImplicitlyExpandDesignTimeFacades 1 calls
84 ms _GenerateAndroidAssetsDir 1 calls
87 ms FindReferenceAssembliesForReferences 1 calls
93 ms _GetProjectReferenceTargetFrameworkProperties 2 calls
103 ms _ComputeAndroidResourcePaths 1 calls
105 ms ResolveProjectReferences 1 calls
122 ms _BuildAdditionalResourcesCache 1 calls
128 ms _CheckTargetFrameworks 1 calls
148 ms _XamarinAndroidBuildAarProguardConfigs 1 calls
195 ms _BuildLibraryImportsCache 1 calls
204 ms _CopyMdbFiles 1 calls
218 ms _ResolveSatellitePaths 1 calls
236 ms _FindJavaStubFiles 1 calls
245 ms ResolveAssemblyReferences 1 calls
259 ms IncrementalClean 1 calls
265 ms _FindCompiledJavaFiles 1 calls
384 ms _CleanGetCurrentAndPriorFileWrites 1 calls
402 ms _AdjustJavacVersionArguments 1 calls
449 ms _SetLatestTargetFrameworkVersion 1 calls
616 ms _ResolveAssemblies 1 calls
2325 ms _CopyFilesMarkedCopyLocal 1 calls
3294 ms _CopyIntermediateAssemblies 1 calls
3582 ms CoreCompile 1 calls
3708 ms _LinkAssembliesNoShrink 1 calls
4267 ms _GenerateAndroidResourceDir 1 calls
5510 ms _ResolveLibraryProjectImports 1 calls
6131 ms _GenerateJavaDesignerForComponent 1 calls
15153 ms _CompileJava 1 calls
15530 ms _GenerateJavaStubs 1 calls
27014 ms _CreateBaseApk 1 calls
34145 ms _CompileToDalvikWithDx 1 calls
41166 ms _UpdateAndroidResgen 1 calls
(* = timing was not recorded because of reentrancy)

Task Performance Summary:
* ms MSBuild 4 calls
0 ms GetFrameworkPath 1 calls
0 ms CheckProjectItems 1 calls
0 ms GetAppSettingsDirectory 1 calls
0 ms CalculateAdditionalResourceCacheDirectories 1 calls
0 ms VectorDrawableCheckBuildToolsVersionTask 1 calls
0 ms ResolveNonMSBuildProjectOutput 1 calls
0 ms GetReferenceAssemblyPaths 2 calls
0 ms GetAndroidDefineConstants 1 calls
1 ms AssignCulture 1 calls
1 ms ReadAdditionalResourcesFromAssemblyCache 1 calls
1 ms GetExtraPackages 2 calls
1 ms ReadLinesFromFile 1 calls
1 ms CreateTemporaryDirectory 2 calls
1 ms GetMonoPlatformJar 1 calls
1 ms GetJavaPlatformJar 1 calls
1 ms AssignProjectConfiguration 1 calls
1 ms CreateCSharpManifestResourceName 1 calls
1 ms ReadImportedLibrariesCache 1 calls
1 ms XmlPeek 1 calls
1 ms GetAndroidPackageName 1 calls
2 ms ReadLibraryProjectImportsCache 1 calls
2 ms GetAddOnPlatformLibraries 1 calls
2 ms CheckDuplicateJavaLibraries 1 calls
2 ms MakeDir 6 calls
2 ms CollectLibraryAssets 1 calls
3 ms AssignTargetPath 10 calls
3 ms Message 17 calls
4 ms ValidatePackageReferences 1 calls
5 ms FindAppConfigFile 1 calls
6 ms RemoveDirFixed 2 calls
8 ms ConvertDebuggingFiles 1 calls
8 ms XamarinBuildAndroidResourceRestore 1 calls
9 ms CreateResgenManifest 1 calls
9 ms CreateAndroidResourceStamp 1 calls
11 ms ConvertToAbsolutePath 1 calls
12 ms CreateProperty 70 calls
13 ms CopyConfigFiles 1 calls
13 ms CollectPdbFiles 1 calls
15 ms GeneratePackageManagerJava 1 calls
16 ms CopyResource 4 calls
17 ms Delete 3 calls
18 ms Hash 1 calls
19 ms CopyGeneratedJavaResourceClasses 2 calls
20 ms GetFilesThatExist 2 calls
23 ms CopyIfChanged 1 calls
30 ms GetPrimaryCpuAbi 1 calls
36 ms XamarinBuildAndroidAarRestore 1 calls
38 ms DetermineJavaLibrariesToCompile 1 calls
78 ms CopyMdbFiles 1 calls
81 ms WriteLinesToFile 6 calls
104 ms AndroidComputeResPaths 2 calls
121 ms GetAdditionalResourcesFromAssemblies 1 calls
128 ms CheckTargetFrameworks 1 calls
142 ms RemoveUnknownFiles 2 calls
146 ms XamarinBuildAndroidAarProguardConfigs 1 calls
195 ms GetImportedLibraries 1 calls
198 ms RemoveDuplicates 2 calls
212 ms FindUnderPath 5 calls
272 ms Touch 13 calls
402 ms AdjustJavacVersionArguments 1 calls
405 ms GenerateResourceDesigner 1 calls
448 ms ResolveSdks 1 calls
461 ms ResolveAssemblyReference 2 calls
595 ms ResolveAssemblies 1 calls
627 ms CreateItem 263 calls
3579 ms Csc 1 calls
3695 ms LinkAssemblies 1 calls
5509 ms ResolveLibraryProjectImports 1 calls
8166 ms GenerateJavaStubs 1 calls
9682 ms Copy 9 calls
15079 ms CreateMultiDexMainDexClassList 1 calls
15150 ms Javac 1 calls
19063 ms CompileToDalvik 1 calls
33129 ms Aapt 3 calls
48058 ms ConvertResourcesCases 3 calls
(* = timing was not recorded because of reentrancy)

Build succeeded.

Time Elapsed 00:02:46.92

The build configuration looks like:

            <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'MyApp-Debug|AndroidEmulator' ">
                <MonoAndroidResourcePrefix>Resources;Resources-MyApp</MonoAndroidResourcePrefix>
                <MonoAndroidAssetsPrefix>Assets;Assets-rnl</MonoAndroidAssetsPrefix>
                <AndroidResgenFile>Resources-MyApp\ResourceMyApp.designer.cs</AndroidResgenFile>
                    <AndroidExplicitCrunch>false</AndroidExplicitCrunch>
                <DebugSymbols>true</DebugSymbols>
                <DebugType>full</DebugType>
                <Optimize>false</Optimize>
                <OutputPath>bin\MyApp-Debug\AndroidEmulator</OutputPath>
                <DefineConstants>TRACE;MyApp;DEBUG</DefineConstants>
                <ErrorReport>prompt</ErrorReport>
                <WarningLevel>4</WarningLevel>
                <ConsolePause>false</ConsolePause>
                <EmbedAssembliesIntoApk>false</EmbedAssembliesIntoApk>
                <RunCodeAnalysis>true</RunCodeAnalysis>
                <AndroidEnableMultiDex>true</AndroidEnableMultiDex>
                <AndroidLinkMode>None</AndroidLinkMode>
                <AndroidUseSharedRuntime>true</AndroidUseSharedRuntime>
                <AndroidSupportedAbis>x86</AndroidSupportedAbis>
                <JavaMaximumHeapSize>2G</JavaMaximumHeapSize>
            </PropertyGroup>

Answers

  • DianaZDianaZ Member ✭✭

    Sorry for late, I answered your question on StackOverflow,you may check it, hope this can help you.

Sign In or Register to comment.