Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Large APK Size #1097

Open
petabyt opened this issue Jun 10, 2020 · 12 comments
Open

Large APK Size #1097

petabyt opened this issue Jun 10, 2020 · 12 comments

Comments

@petabyt
Copy link

petabyt commented Jun 10, 2020

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?

@yms2772
Copy link

yms2772 commented Jun 11, 2020

+1
APK size is so big even using -ldflags="-s -w", because of this, the Play Store tells you to optimize your app.

@petabyt
Copy link
Author

petabyt commented Jun 11, 2020

@yms2772 I didn't realize that. Typical Android Studio apps come out as around 500kb I think.

@yms2772
Copy link

yms2772 commented Jun 11, 2020

@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.

@andydotxyz
Copy link
Member

andydotxyz commented Jun 11, 2020

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.

@andydotxyz
Copy link
Member

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.

@andydotxyz
Copy link
Member

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.

@andydotxyz
Copy link
Member

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

@andydotxyz
Copy link
Member

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.

@Noofbiz
Copy link

Noofbiz commented Jul 16, 2020

I know with wasm you can drastically reduce the binary size by avoiding the fmt library. Not sure if that works for android though

@andydotxyz
Copy link
Member

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.

@mrjrieke
Copy link
Contributor

I'm pretty sure you can also target the architecture in the Google play developer account.

@MatejMagat305
Copy link
Contributor

I meet https://github.com/cnlohr/rawdrawandroid, which can maybe be usefull to reduce binary size on android ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants