The resulting size of the Release application with Esri is too large.

1697
4
Jump to solution
04-14-2023 02:46 AM
PavelGraňák
New Contributor II

Hello, 

I am creating a project in .Net MAUI (net6.0) (only for Android 11+ and Windows UI3) and I have used your library from NuGet (Esri.ArcGISRuntime.Maui 100.15.0.-preview4), and everything is working as expected (displaying a map from our internal map server, searching for points, displaying nearby addresses, etc.). However, I have encountered one issue, that when I built the application in Release mode, the resulting size of the application was around 140 MB. When I removed Esri.ArcGISRuntime.Maui from the application and built it again in Release mode, the size of the application was around 35 MB.

My question is whether it is possible to reduce the size of my resulting application while still using your excellent component? We are using Esri in other projects, such as Winform .Net 4.8 and UWP.

In the MAUI project, the following settings are configured:

  • Android package format = apk
  • Enable trimming = Release & net6 …
  • Trimming granularity = Link

If needed, I can provide the complete XML configuration of the project.

Best regards,

Pavel Graňák

Translator ChatGPT: CZE --> EN

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
MatveiStefarov
Esri Contributor

Hello Pavel,

If you look at the APK, you will probably see the "lib" folder taking up the most space.  That's where Runtime puts its ABI-specific native libraries.  By default, MAUI creates broadly compatible Android packages.  This means that all 4 versions of Runtime native libraries are in the package, adding about 30 MB each.

If package size is important and you know exactly what architecture your devices use, then you might be able to reduce the number of supported ABIs -- and the number of libraries that have to be included.

For example, our MAUI samples app creates a 210 MB package by default.  But if I target only arm64, the size is reduced to 101 MB.  This can be done by adding <RuntimeIdentifiers>android-arm64</RuntimeIdentifiers> to the project file.  See if this helps!

View solution in original post

4 Replies
MichaelDavis3
Occasional Contributor III

Not sure what you can do to reduce the size, but this is typical from what I've seen in apps (Android & iOS) using the ESRI Runtime.  Is there a specific issue with the app being that size?

0 Kudos
PavelGraňák
New Contributor II

Hello, the application will be deployed within the corporate closed network. Distribution will be carried out using Sideloading on cce 200 (android phone or windows Panasonic FZ-M1) devices that have a limited data plan. We plan to distribute new improvements and modules in the application in 14 day cycles. And for that reason, the size of the application is crucial. However, if it is not possible to reduce the size of Esri Runtime components, then we will have to adapt somehow.
Best regards

 

Translator google CZE-->EN

0 Kudos
MatveiStefarov
Esri Contributor

Hello Pavel,

If you look at the APK, you will probably see the "lib" folder taking up the most space.  That's where Runtime puts its ABI-specific native libraries.  By default, MAUI creates broadly compatible Android packages.  This means that all 4 versions of Runtime native libraries are in the package, adding about 30 MB each.

If package size is important and you know exactly what architecture your devices use, then you might be able to reduce the number of supported ABIs -- and the number of libraries that have to be included.

For example, our MAUI samples app creates a 210 MB package by default.  But if I target only arm64, the size is reduced to 101 MB.  This can be done by adding <RuntimeIdentifiers>android-arm64</RuntimeIdentifiers> to the project file.  See if this helps!

PavelGraňák
New Contributor II

Hello, thank you for your advice, I made a modification in the *.scproj project file and after building the application in Release, the application is currently about 52MB, which is amazing. Thank you very much for your help.

I am attaching a fragment from *.csproj

<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net6.0-android|AnyCPU'">
<Optimize>True</Optimize>
<ApplicationTitle>DampoMAUI</ApplicationTitle>
<DebugSymbols>False</DebugSymbols>
<AndroidPackageFormat>apk</AndroidPackageFormat>
<RunAOTCompilation>False</RunAOTCompilation>
<TrimMode>link</TrimMode>
<AndroidUseAapt2>True</AndroidUseAapt2>
<ApplicationId>cz.xxxxxxxx.dampo.client.mobile</ApplicationId>
<RuntimeIdentifiers>android-arm64</RuntimeIdentifiers>
</PropertyGroup>