Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
357 views
in Technique[技术] by (71.8m points)

c# - Please help reducing Xamarin.Android apk size

I have been working on an Android app but size seems very large! I have pro guard enabled, link all enabled but dosent seem to do much. I have four small images but their size is around 5-10kb each. The only time it is smaller is when I run with shared runtime but that's not Ok for publishing. These are my only build warnings:

Warning     can't write resource [META-INF/MANIFEST.MF] (Duplicate zip entry [classes.jar:META-INF/MANIFEST.MF])    

Warning     can't write resource [META-INF/MANIFEST.MF] (Duplicate zip entry [internal_impl-22.2.1.jar:META-INF/MANIFEST.MF])

Do these warnings have anything to do with issue?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The apk is about 14MB, including armeabi, amreabi-v7a, x86. Link setting is: 'Sdk and User Assemblies'

Nothing seems amiss with that apk size.

A "Hello World" Xamarin.Android app supporting just one ARCH type that is linking SDK and User assemblies would be around 4MB (for ARCH type armeabi-v7a).

Each additional included ARCH type is going to add another set of libmonodroid.so and libmonosgen-2.0.so... Remember Mono running on Android is an NDK application and thus must include native code for each ARCH type. The APK size is NOT the size of the actual installed application on the physical device as the Android OS will strip the actual needed native libraries from the APK during the install.

So in your case of including three arch types, you are looking at 9+MB just for the Mono/MonoDroid runtime:

./armeabi:
   144912  libmonodroid.so
  2835260  libmonosgen-2.0.so

./armeabi-v7a:
   144916  libmonodroid.so
  2790212  libmonosgen-2.0.so

./x86:
   128436  libmonodroid.so
  3449836  libmonosgen-2.0.so

Understanding the Constituent Pieces of APKs in Xamarin.Android


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...