x/mobile: reduce size of generated artifacts #40348
Closed
Labels
Milestone
Comments
/cc @hyangah |
i believe it will be somewhere here: |
Another way to reduce the size of the APK would be to generate an AAB instead, which would mean an x86 device would only receive x86 code and an ARM device would only get ARM code. As it currently stands, the APK contains 4 copies of all native code, which totals about 100 megabytes for my app after zip compression. |
@BenLubar I came across this article which doesn't use gomobile. It may be possible to achieve my suggestions with the author's approach. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The size of Go builds can be shrunk with the
ldflags
build option like this:go build -ldflags '-s -w' -o my_app.exe
This can be reduced further with UPX as such:
upx -o my_app_min.exe my_app.exe
More on this here.
I'm able to pass the
ldflags
into gomobile like this:gomobile bind -ldflags '-s -w' -target=android github.com/my/app
.I would like to "inject" UPX somewhere in the bind process to reduce the size of my generated
.aar
and.framework
.A possible flow is this:
go build -ldflags '-s -w' -o my_app.exe
upx -o my_app_min.exe my_app.exe
gomobile bind --from-build=my_app_min.exe -target=android github.com/my/app
The text was updated successfully, but these errors were encountered: