question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Improve grpc library file size in iOS and Android build

See original GitHub issue

The document provides a way to strip debug symbols from libgrpc.a, which reduce the file size from about 100m to 18m. Meanwhile, the stripped libgrpc.a is still a FAT file, which contains x86_64, armv7 and arm64 architecture. Since armv7 is already deprecated, we can use lipo command to remove x86_64 and armv7 from it.

lipo libgrpc.a -remove x86_64 -remove armv7 

The file size can be reduced to ~6M, if you are targeting arm64 devices only (iPhone 5s and later).

The libgrpc_csharp_ext.so for Android platform can also be stripped by following command:

##Choose proper architecture
[NDK_PATH]\toolchains\aarch64-linux-android-4.9\prebuilt\windows-x86_64\aarch64-linux-android\bin\strip.exe" libgrpc_csharp_ext.so

The file size can be reduced from 46M to 3M

Hope these tips would help someone who hesitated because of client library file size.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:9
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
parkycaicommented, Sep 2, 2022

Hey, I was trying your solution but getting this error. input file (libgrpc.a) must be a fat file when the -remove option is specified. Do you have any idea why?

Is it already thinned? A FAT file means it contains multiple archs in it. Try lipo libgrpc.a -archs to find out which archs it contains.

0reactions
parkycaicommented, Nov 7, 2022

It looks like grpc-unity-packaged is removed from grpc daily build page. Where can I download the latest version? @triste24 @bartutiryakioglu

Meanwhile, could you try that whether the version in this repo is still working? libgrpc.a

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why is Grpc.Core NuGet package so big?
It turns out that for Android there are native libraries for three different architectures each around 50 MB and for iOS there is...
Read more >
Build client-server applications with gRPC
The downside of using Cronet is the APK size increase, as adding the binary Cronet dependency will add >1MB to the app size,...
Read more >
Performance Best Practices
A user guide of both general and language-specific best practices to improve performance.
Read more >
Serving with gRPC - BentoML Documentation
Definition: The maximum message length in bytes allowed to be received on/can be send to the server. By default we set to -1...
Read more >
Overview | Protocol Buffers Documentation
Protocol buffers provide a serialization format for packets of typed, structured data that are up to a few megabytes in size. The format...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found