Xamarin app deploy - Are all dependencies included in app package (apk)?

Multi tool use
Xamarin app deploy - Are all dependencies included in app package (apk)?
I'm new to Xamarin and don't know how solution deployment actually works.
Lets assume I have dependencies in my project as shown in the diagram below:Does this mean that deploying the app will cause all projects to be included? For this particular case,
Mobile
app doesn't use the CoreServices
, which calls RestService
and Data
, but it is also calling the same CoreServices
that Web
uses.
Mobile
CoreServices
RestService
Data
CoreServices
Web
3 Answers
3
Your app will include everything that is required by any referenced assembly or project. For example: If BP.Mobile references CoreServices which references RestServices all these project build results will be included in your app that references BP.Mobile. Plus all the assemblies coming with NuGet-packages.
What is inside your app can be easily seen if you analyze your apk with Android Studio. Or rename your apk to zip and un-package it.
Your statement about everything referenced being included is true when the package is built with no linking. Otherwise, "Linking is based on static analysis. Consequently, anything that depends upon the runtime environment won't be detected". Linking results in a significantly smaller package (18% of original size), but requires the Mono runtime to be deployed onto the target device.
– sαmosΛris
Jul 2 at 18:49
On your library properties, make sure Copy Local is set to True. This will make a local copy of the library to the device.
Linking on Android
Xamarin.Android applications use a linker to reduce the size of the
application. The linker employes static analysis of your application
to determine which assemblies are actually used, which types are
actually used, and which members are actually used. The linker then
behaves like a garbage collector, continually looking for the
assemblies, types, and members that are referenced until the entire
closure of referenced assemblies, types, and members is found. Then
everything outside of this closure is discarded.
Linker Behavior
The primary mechanism for controlling the linker is the Linker
Behavior (Linking in Visual Studio) drop-down within the Project
Options dialog box. There are three options:
ref: https://docs.microsoft.com/en-us/xamarin/android/deploy-test/linker
Note: The Advanced button (bottom right) brings up a dialog for setting the target architecture (ARM, x86, x64, etc...) along with some other options that probably shouldn't be messed with typically.
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
docs.microsoft.com/en-us/xamarin/android/deploy-test/linker
– sαmosΛris
Jul 2 at 13:04