Hi,
@Cheesebaron and all other members of the Xamarin forum. We have built an android app using Xamarin android. We have used v4 and v7 packages since they are almost mandatory and our apk file size is already 20 MB. Most of the space (around 7MB) is taken up by the v4 and v7 packages.
We wanted to know if there is a solution to this. File size is a huge concern and people tend to avoid such bulky apps.
Any sort of help to fix this issue will be really helpful. C# is our forte, hence Xamarin has been a great friend, but for this major concern.
Regards,
Pranjal Vatsa
Hi @PranjalVatsa,
You can reduce the app size by using linking : https://developer.xamarin.com/guides/android/advanced_topics/linking/.
and Turn on ProGuard : https://developer.xamarin.com/guides/android/deployment,testing,_and_metrics/publishing_an_application/part_1-_preparing_an_application_for_release/#ProGuard.
Read these articles before release so you can reduce the app size successfully :
https://developer.xamarin.com/guides/android/deployment,testing,_and_metrics/publishing_an_application/part_1-_preparing_an_application_for_release/
http://motzcod.es/post/112072508362/how-to-keep-your-android-app-size-down
https://developer.xamarin.com/guides/android/advanced_topics/application_package_sizes/
http://developer.sonymobile.com/2012/01/31/tips-for-reducing-apk-file-size/
Answers
Hi @PranjalVatsa,
You can reduce the app size by using linking : https://developer.xamarin.com/guides/android/advanced_topics/linking/.
and Turn on ProGuard : https://developer.xamarin.com/guides/android/deployment,testing,_and_metrics/publishing_an_application/part_1-_preparing_an_application_for_release/#ProGuard.
Read these articles before release so you can reduce the app size successfully :
https://developer.xamarin.com/guides/android/deployment,testing,_and_metrics/publishing_an_application/part_1-_preparing_an_application_for_release/
http://motzcod.es/post/112072508362/how-to-keep-your-android-app-size-down
https://developer.xamarin.com/guides/android/advanced_topics/application_package_sizes/
http://developer.sonymobile.com/2012/01/31/tips-for-reducing-apk-file-size/
Looks good. I'll give it a try. @Yksh.Leo
Thanks @Yksh.Leo. Linking all assemblies reduced apk file size by almost 40%. Thanks for the pointers..
@YkshLeo
Hi Tried linking and progurad enable options but still my hello world app have 18 mb. Cannot reduce the app size. My project is pcl project. Could you please help me any one
From VS Menu Project-"Your App name Properties" -> Android Options -> Linker -> Linking
select SDK and User Assemblies then build.
App crashes when I choose **SDK and User Assemblies ** could any one tell me the reason
Could you please post the debug output here? With Diagnostics enabled.
The linker is probably removing code that is used in runtime.
Still the xamarin APK file size is 10 size bigger than the APK of Android studio. Which is not acceptable for the client. We are c# lovers and has a lot of hopes with xamarin. I Think the xamarian developer should come up and give us a good solution to carry on the development and release the product. Please help.
Hi,
1) Install 7-zip
2) Build and deploy a RELEASE version to you mobile phone
3) go to your app/bin/Release directory
4) open the appname.Signed.apk file with 7-Zip (Open Archive)
5) Take a screenshot
6) Navigate to assemblies, take a screenshot.
7) Navigate to lib, take a screenshot.
Post the screenshot of 4,6 and 7 here.
@AlbertK , i followed what steps you have been suggested. But still I am getting same issue. My app getting crashed when i linking with "Sdk and User assembly"
The reason is hard to tell without information about the exact exception, but this could be due to a runtime type resolution. Think about the following class
You do not create an instance direcly, but access the type via reflection – for whatever reason
If you link the assembly that contains
MyClass
, the class will be removed, since the linker will assume that it's not used. Therefor you cannot access the type via reflection and your application crashes – basically.@Amit02 I am also having save issue app gets crash when i set linking to Sdk and User Assemblies..Have u found any solution .