Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Post Modern API: gRPC for Android

Avatar for Moud Moud
November 28, 2018

Post Modern API: gRPC for Android

Most of mobile apps today need communicating with a server. And most of them rely on REST APIs to do so, putting aside how it’s implemented or whether it respects the REST Architecture or not. In a context of distributed and autonomous back end teams, adopting micro-services as an architectural approach, many developers have been arguing about the efficiency of loosely typed interfaces of REST.

Since 2015 when Google open sourced gRPC many of them have been using it alongside Protocol Buffers as message format instead of REST and JSON.
But not all of the front end developers followed through, which made backend developers duplicate efforts to add specific endpoints in REST.
In this talk we will see how Android Developers can make faster server calls, while saving battery life and data usage, by creating a gRPC client for Android.

Avatar for Moud

Moud

November 28, 2018
Tweet

More Decks by Moud

Other Decks in Technology

Transcript

  1. message Member { string id = 1; string last_name =

    2; string first_name = 3; string email = 4; } message GetMemberRequest { string id = 1; } message GetMemberResponse { Member member = 1; } service MemberServices { rpc GetMember(GetMemberRequest) returns GetMemberResponse }
  2. apply plugin: 'com.android.application' apply plugin: 'com.google.protobuf' ... dependencies { //For

    Android it's recommended to go with the lite version instead of protobuf-java. implementation 'com.google.protobuf:protobuf-lite:3.0.1' }
  3. protobuf { ... // Configure the protoc executable protoc {

    // Download from repositories artifact = 'com.google.protobuf:protoc:3.0.0' } ... }