目标是在Android上使用gRPC进行通信,当然是在Android的Native层的需求,应用层要使用gRPC会方便的多,搜一下资源,build.gradle配置一下依赖就能用了。下面在Ubuntu系统中来编译在Android Native运行的gRPC的库,分为:
1 下载gRPC源码
2 使用Android源码自带的编译工具编译gRPC
3 使用gRPC
下载gRPC源码
在github下载gRPC项目,然后更新子模块:
git clone https://gitee.com/githubplus/grpc.git
cd grpc
git tag
git checkout v1.20.0
更新submodule:
git submodule update --init
直接更新速度特别慢,甚至n次的中断,不知道什么岁月才能更新完,因此请修改.gitmodules文件,替换其中的github源为gitee源
vim .gitmodules
// replace content in .gitmodules
[submodule "third_party/zlib"]
path = third_party/zlib
url = https://gitee.com/githubplus/zlib
# When using CMake to build, the zlib submodule ends up with a
# generated file that makes Git consider the submodule dirty. This
# state can be ignored for day-to-day development on gRPC.
ignore = dirty
[submodule "third_party/protobuf"]
path = third_party/protobuf
url = https://gitee.com/githubplus/protobuf.git
branch = 3.0.x
[submodule "third_party/gflags"]
path = third_party/gflags
url = https://gitee.com/githubplus/gflags.git