ipa and apk size issue - xamarin.forms

I am working on Xamarin.Forms project everything going smooth earlier but now I am facing very strange issue while creating ipa and apk file.
Till One Day before while i was creating apk and ipa the size was near about 25-30MB
but suddenly it's increases to more than 700MB.
Now while i am creating ipa and apk file its size showing more than 700MB.
I tried by checking and unchecking Linker Behaviour to
1-Don't Link
2- Link SDK assembly only
3-Link All SDK.
but not find suitable.
Please Help to outcome from this issue, any thing i am missing ?

Related

Xamarin forms iOS changed AppIcons but remains showing old default

Starting from a standard Xamarin forms app template and changing the app icons in assets.xcassets, I am unable to make this take effect. The initial xamarin icon keeps showing when deployed to physical devices.
In assets.xcassets, I added all the required image sized.
I ensured that in plist info this asset was set as app icons source.
I have tried cleaning, rebuilding and deleting from the ipad and iphone I am testing with. No success.
I tried deleting the default asset and creating a new one, and make pinfo point to this, and still the old Xamarin icon shows up. This makes me think that there is a cache somewhere on either my windows pc, on which I am developing using vs2019, or on the mac which VS is connected to for doing the actual build, and this is not getting updated, since otherwise that old icon should not exist any longer.
I did read this answer
Xamarin forms: Launcher icon for ios
Which indicates that the OP has a problem with a mismatched path to the asset, but that does not seem to be the case for me. The xcasset folder is at the root of the ios project. As this is simply the default test project it is app1/App1.ios/Fawk.xcassets and the entry in pinfo is
XSAppIconAssets
Fawk.xcassets/AppIcons.appiconset
Does this make any kind of sense?
Edit: Tried vs2019, xamarin forms template. Deleted default asset in assetcatalogs under ios, created a new one, set all my custom icon images (png), updated info.plist/visual assets/appicon to my new asset and then ran it on a physical device. The default xamarin icon is what shows up. This seems to indicate it is not a cache issue, as I suspected, but... something else...
You can right-click Assets.xcassets and view it in the folder, there is a json file in it, please check if the file name is correct.
According to the official documentation, if you are not connected to a Mac, it will only display the original image. For more information, you can check: https://learn.microsoft.com/en-us/xamarin/xamarin-forms/deploy-test/hot-restart#limitations

Still getting ITMS-90809: Deprecated API Usage after using --optimize=force-rejected-types-removal

This has been killing me for the last couple of days. I have read everything I can find on this error and have done what xamarin says but it still doesn't work.
I can't get my builds to get through azure pipeline xamarin.ios build and deploy to apple.
When I build locally I get messages like
MTOUCH : warning MT1502: One or more reference(s) to type 'UIKit.UIWebView' already exists inside 'Xamarin.Forms.Platform.iOS, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null' before linking
with a companion message that says no references after linking
when I use --warn-on-type-ref=UIKit.UIWebView with the optimize arg.
When I build on azure in my pipeline, I only see the MT1502 but nothing saying anything after linking. The build gets submitted to Apple and fails because of the ITMS message.
I don't know what to do. I am using the latest macOS vm image, mono 6.8.0.123, xamarin.ios 13.16.0.13, xcode 11.4.1. The pipeline worked fine before April 30 deadline, now no matter what, I can't get the linker to strip UIWebView.
Let me know what other info would be helpful. I am completely stuck at this point.
Thanks.
I just got my build to pass Apple's inspection.
What ended up working for me was building locally and packaging the ipa file. On my mac I then changed the ipa extension to zip and unzipped it. I used terminal to go to the YOURAPPNAME.app "folder" and used grep -r UIWebView . to search for references. Don't forget the . so it searches the current directory. I missed that at first and got some message that grep was listening on stdin.
For me that resulted in a line like this:
Binary file ./Frameworks/PersonalizedAdConsent.framework/PersonalizedAdConsent matches
Now, the important thing to note is the linker never warned about this, so I was completely unaware of it. In my case it was part of Firebase/Admob. I was only one release behind and updating to the latest fixed my problem.
I still am using --optimize=force-rejected-types-removal --warn-on-type-ref=UIKit.UIWebView -warnaserror:1503 as my mtouch args. But builds now get through.
I hope this helps point you guys in the right direction, I've spent the last 3 days just trying to get builds to upload reading every post I could find on the web on this problem.
Solved !! I had to update the way how nugets are included to the iOS project .csproj file. The problem was that linker despite the --optimize=force-rejected-types-removal flag was not removing the UIWebView component form Xamarin.Forms 4.6 probably because it did not see it.
My project was created over two years ago and I was still using the packages.config file. After the update the flag started to work and grep query returned 0 :). The best way is to compare the old .csproj file with freshly created iOS project .csproj file and see how VS is referencing nugets.

Using AOT and LLVM makes app size too large when installed on the device

I tried using AOT and LLVM to reduce start up time in my xamarin forms app on android. It really made trick. I had around 10-12secs and now google firebase reports between 2-7secs based on the device as shown below.
What my settings are as followings;
- Link SDK and User assemblies
- Bundle into native assemblies
- Proguard
- no-write-symbols,nodebug
- Separate Apk for each Abis
Project file for related group looks like as below;
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AndroidUseSharedRuntime>False</AndroidUseSharedRuntime>
<DebugType>
</DebugType>
<AndroidLinkMode>Full</AndroidLinkMode>
<EmbedAssembliesIntoApk>true</EmbedAssembliesIntoApk>
<AndroidCreatePackagePerAbi>true</AndroidCreatePackagePerAbi>
<JavaMaximumHeapSize>1G</JavaMaximumHeapSize>
<AotAssemblies>true</AotAssemblies>
<EnableLLVM>true</EnableLLVM>
<AndroidAotAdditionalArguments>no-write-symbols,nodebug</AndroidAotAdditionalArguments>
<DebugSymbols>false</DebugSymbols>
<BundleAssemblies>true</BundleAssemblies>
<AndroidEnableMultiDex>True</AndroidEnableMultiDex>
<EnableProguard>true</EnableProguard>
<Debugger>Xamarin</Debugger>
<AndroidSupportedAbis>armeabi-v7a;x86;x86_64</AndroidSupportedAbis>
<AndroidLinkSkip>Akavache;Akavache.Sqlite3;SQLiteNetExtensions;SQLiteNetExtensionsAsync;SQLite.Net;SQLite.Net.Async;Syncfusion.DataSource.Portable;Syncfusion.Data.Portable;Syncfusion.Pdf.Portable;Syncfusion.SfDataGrid.XForms;Syncfusion.SfNumericUpDown.XForms;Syncfusion.SfDataGrid.XForms.Android;Syncfusion.SfNavigationDrawer.Android;Syncfusion.SfNavigationDrawer.XForms;Syncfusion.SfNavigationDrawer.XForms.Android;Syncfusion.SfSchedule.XForms;Syncfusion.SfSchedule.XForms.Android;Syncfusion.SfSchedule.Android;Syncfusion.Compression.Portable;Xamarin.GooglePlayServices.AppIndexing;Xamarin.Insights;Splat;Xamarin.GooglePlayServices.Basement;Xamarin.FireBase.AppIndexing;Xamarin.FireBase.Common;Xamarin.GooglePlayServices.Gcm;</AndroidLinkSkip>
<AndroidEnableMultipleDex>true</AndroidEnableMultipleDex>
<AndroidExplicitCrunch>true</AndroidExplicitCrunch>
</PropertyGroup>
PROBLEM;
App size increased as expected but it is not the Apk size problem for me, rather installed size on device. here are the values.
APK is 20mb using single apk, settings above but no AOT no LLVM
APK separate apks per abi are 16mb, settings above but no AOT no LLVM
single apk 49 mb, , settings above but with AOT + LLVM
separate Apks per abi are 26 mb,settings above with AOT + LLVM a
Until here, everything seems perfect. I can accept 6mb-10mb increase even it is still so high amount but the difference is installed size of the app on the device. without AOT is around 30mb installs. with AOT+LLVM 100mb+
When I extract the apk, i can see what is in the apk.
Capture below is from lib folder (biggest folder) without using AOT and Bundle into Native assemblies
Capture for with AOT+LLVVM.. see the yellow highlighteds are indeed what we need to install the apk according to the previous apk. I dont know if I need any extra library to run AOT but why those blue underlined 3rd party libraries are there. they are supposed to be bundled into native assemblies as in the first screenshot.
Do I understand it wrong or Xamarin has bug on using AOT with Bundles into Native assemblies?

Xamarin.Forms - Xamarin.Forms.Maps broken references in Droid Project

I need to implement Map functionality into an application that I'm building.
And I was folliwing this guide.
I downloaded the package and did all of the configuration.
I haven't implemented the Map class into my project yet, I only did the configuration required for both platforms (Android and iOS).
The Portable project and the iOS project are fine, the problem here is the Android project.
It has some broken references, these ones:
And when I try to compile the Android project, I get this error and these warnings:
Can anybody give me a hand? Thanks in advance.
EDIT:
As a sidenote, I'm using the Sdk installed by Android Studio, and that one has the latest Google Play Services installed.
UPDATE:
I just upgraded the version of my Xamarin.GooglePlayServices one by one (the one listed up there in the first image) for some reason it downloaded a really old version of those. So I just upgraded them, and it seems those references are fine now.
But I still get the error:
The "ResolveLibraryProjectImports" tasks failed unexpectedly.
SOLUTION:
I unloaded the Android project, added this:
<UseShortFileNames>True</UseShortFileNames>
To every property group in the .csproj file.
Load my android project back, and it all worked fine now.

Generate apk file for meteor app

I have a project is working for android browser. Is there a way to generate the apk file?
Also, are there anything that I shoud know before generating the apk file?
There are a few steps to follow in order to generate the Android application file (.apk) from a meteor app:
meteor install-sdk android
Have the mobile-config.js file in your project root (mobile-config.js example)
meteor add-platform android
meteor build ~/your-output-dir --server=yourapp.meteor.com
Then you will have your .apk file in ~/your-output-dir/android/unaligned.apk
If you want to proceed and submit to Google Play Store, here are the steps to follow: https://guide.meteor.com/mobile.html#submitting-android
Hope this helps!
You can build an APK file with meteor build command.
Read more about it in the docs: http://docs.meteor.com/#/full/meteorbuild or by typing meteor help build in your terminal.
Starting with Meteor 1.2, the bundled Android tools have been removed and a system-wide install of the Android SDK is now required. This should make it easier to keep the development toolchain up to date and helps avoid some difficult to diagnose failures. The meteor install-sdk command no longer attempts to download and install the Android tools for you (it has been deprecated and just points you to these instructions).
like imslavko says, meteor build works pretty fine, also if you are looking for more information take a look on this Meteorpedia
It work for me
Reegards
As of now playstore has started giving warning while uploading APK about unoptimised bundle and insisting for uploading Android app bundle.
Insted of generating APK why not generate .aab of your project and reduce size of the application.
For people wondering about how to generate .aab for your existing project can read my blog here:
My blog link

Resources