When building the simple Hello World Fyne example, the output APK size is almost 60mb (58.3 on my end).
This is very large compared to apps built with Android Studio, and is a
problem with releasing production apps in the future.
Is there any possibility of a smaller APK size?
+1
APK size is so big even using -ldflags="-s -w", because of this, the Play Store tells you to optimize your app.
@yms2772 I didn't realize that. Typical Android Studio apps come out as around 500kb I think.
@yms2772 I didn't realize that. Typical Android Studio apps come out as around 500kb I think.
Yes, it seems that there are many resources that are not used in apk.
In Android Studio, there is a feature which is Android App Bundle that optimizes and reduces apk size.
There are a number of things at play here. To work across all platforms we embed a lot of resources. That means the current minimym app size is about 15MB - we will, at some point, find a way to determine which resources are not needed and strip them out. Much of this is fonts which we could reduce if we find a cunning way to implement localisation (i.e. fonts downloaded and cached when needed?).
Additionally on mobile there are some libraries packaged that we need to slim out as I don't think all are needed.
Lastly the Android bundles build for all supported architectures by default (4) which massively inflates the build size. On the develop branch is an enhancement for the fyne package which allows you to build per-architecture instead. So the default of android (i.e. arm, arm64, 386, amd64) is around 60mb but using android/arm produces a binary at around 15MB - similar to what desktop apps come out at.
FYI the fonts seem to add around 8MB at the moment, whilst icons are just 100KB.
Hopefully we can find a clever way to address the font packaging and app sizes will go down dramatically.
After looking into it more the fonts seem to compress well and take up less than 1MB in the final binary, so it looks like elsewhere is where we hunt to reduce below the 15MB app mark.
It may be a good sign that in go 1.15 there are marked improvements to binary size which we should also benefit from golang/go#6853
In case anyone was holdong out hope for the <1MB app size this is not going to be possible - we need to ship the Go runtime in every app so it's not going to be possible to deliver apps as slim as vanilla Android or iOS binaries as their runtimes are installed in the OS and do not have to be packaged.
I know with wasm you can drastically reduce the binary size by avoiding the fmt library. Not sure if that works for android though
I'm pretty sure that most apps (and indeed the toolkit) will need to use formatting of strings, so I don't know that will help us a huge amount. It is certainly worth us checking that we don't import any code that's not used - but at the end of the day there is a lot involved in showing graphical windows etc.
I'm pretty sure you can also target the architecture in the Google play developer account.
Most helpful comment
It may be a good sign that in go 1.15 there are marked improvements to binary size which we should also benefit from golang/go#6853