I follow the steps in the gRPC documents and record my steps in this article.
- Define your proto file and place it under your Android Java Client project folder.
2. Using python module “grpcio” and “grpcio-tools” to generate your python server configuration and protocol objects.
3. Set up Python Server
In the last step, we generated two files, *_pb2.py and *_pb2_grpc.py, which contained objects of python gRPC protocol and settings. In the purpose of using them in a clean way, we’ll define a new server object and set up a server folder.
Python_gRPC_Server
- interaction_pb2.py
- interaction_pb2_grpc.py
- InteracterServer.py
Define Server which maintains the connection settings and API usage.
- run.py
Here we could use the APIs and add other services
4. Set up Android Java Client
(Please notify TAG “// <!Edit Here> — />” in the files below.)
- Import gRPC to Global Gradle
- Import gRPC to APP Gradle
- Add Network permission
- Setup UI
- Setup Android gRPC Client Connection
- Setup Protocol setters and getters
Check out my GitHub ~