Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
gRPC on Android @DroidconSF Report
Search
TakuSemba
November 20, 2017
Technology
640
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
gRPC on Android @DroidconSF Report
TakuSemba
November 20, 2017
More Decks by TakuSemba
See All by TakuSemba
Customize & Debug ExoPlayer @droidkaigi 2020
takusemba
0
2.1k
Jetpack Compose
takusemba
3
3.7k
Protobuf in Kotlin
takusemba
2
2k
Single Activity with MVVM
takusemba
4
1.4k
KotlinConf Report @ca.kt#7
takusemba
2
500
Request in a QUIC way @shibuya.apk#28
takusemba
2
1.1k
Lint for Kotlin @R.kt#3
takusemba
3
1.6k
Auto Release @potatochips#48
takusemba
1
1.3k
Media streaming on Android @droidkaigi 2018
takusemba
6
8.3k
Other Decks in Technology
See All in Technology
AI時代の開発生産性を捉え直す — 経営と現場をつなぐ「開発組織のオブザーバビリティ」— / AI Dev Ex Conference 2026
tkyowa
0
190
発表と総括 / Presentations and Summary
ks91
PRO
0
140
企業でAWS Organizationsを動かすための組織設計の考え方
nrinetcom
PRO
1
110
第67回コンピュータビジョン勉強会CVPR2026読会前編
tsukamotokenji
0
160
AIが実装を自走する時代の認知負債との戦い
lycorptech_jp
PRO
2
660
【Claude Code】鹿野さんに聞く 私の推しの並行開発環境 大公開 / claude-code-parallel-2026-07-15
tonkotsuboy_com
13
8.8k
関数型の考えを TypeScript に持ち込んで、テストしやすい純粋関数を増やす / Pure at the Core, Effects at the Edge: Bringing Functional Thinking into TypeScript
kaminashi
2
130
ファミコンでPHPを動かす / PHP on the Famicom
tomzoh
2
480
世界、断片、モデル。そして理解
ardbeg1958
1
130
副作用のある Lambda でも Lambda Power Tuning は使えるのか / lambda-power-tuning-side-effects
koukihosaka
1
120
Alphaモジュール使っていいのかい!?いけないのかい!?どっちなんだいっ!?
watany
1
290
AIレビューはどこまで任せられるのか?自動化と人が背負うレビューの境界
sansantech
PRO
3
1.1k
Featured
See All Featured
GraphQLの誤解/rethinking-graphql
sonatard
75
12k
How People are Using Generative and Agentic AI to Supercharge Their Products, Projects, Services and Value Streams Today
helenjbeal
1
240
Music & Morning Musume
bryan
47
7.3k
How Software Deployment tools have changed in the past 20 years
geshan
0
34k
Marketing Yourself as an Engineer | Alaka | Gurzu
gurzu
0
260
Balancing Empowerment & Direction
lara
6
1.2k
Java REST API Framework Comparison - PWX 2021
mraible
34
9.5k
Primal Persuasion: How to Engage the Brain for Learning That Lasts
tmiket
0
390
Unsuck your backbone
ammeep
672
58k
For a Future-Friendly Web
brad_frost
183
10k
Data-driven link building: lessons from a $708K investment (BrightonSEO talk)
szymonslowik
1
1.2k
Technical Leadership for Architectural Decision Making
baasie
3
440
Transcript
gRPC on Android TakuSemba CyberAgent.Inc
@takusemba https://github.com/TakuSemba
Droidcon SF
None
What’s gRPC?
gRPC ɾProtocol Buffers ɾRemote Procedure Call ɾHTTP/2
ɾProtocol Buffers ɾRemote Procedure Call ɾHTTP/2 gRPC
ɾProtocol Buffers ɾRemote Procedure Call ɾHTTP/2 gRPC
What’s Protocol Buffers?
ɾBinary based transmission Protocol Buffers ɾAvailable for many languages ɾFaster
than Json
ɾBinary based transmission ɾAvailable for many languages ɾFaster than Json
Protocol Buffers
ɾBinary based transmission ɾAvailable for many languages ɾFaster than Json
Protocol Buffers
Protocol BuffersͰͷ௨৴jsonͱൺͯૣ͍ͷ͔ IUUQTRJJUBDPNUBLVTFNCBJUFNTGFBCEBEDFEEC
Let’s gRPC
message CoffeeRequest { string name = 1; } Request //coffee.proto
message CoffeeResponse { int32 price = 1; string name =
2; string message = 3; } Response //coffee.proto
service Coffee { rpc Order (CoffeeRequest) returns (CoffeeResponse) {} }
Service //coffee.proto
Service service Coffee { rpc Order (CoffeeRequest) returns (CoffeeResponse) {}
} service Coffee { rpc Order (stream CoffeeRequest) returns (CoffeeResponse) {} } service Coffee { rpc Order (CoffeeRequest) returns (stream CoffeeResponse) {} } service Coffee { rpc Order (stream CoffeeRequest) returns (stream CoffeeResponse) {} }
syntax = "proto3"; option java_package = "com.takusemba.grpc.android.protos"; option go_package =
"protos"; package Coffee; message CoffeeRequest { string name = 1; } message CoffeeResult { string message = 1; } service Coffee { rpc Order (CoffeeRequest) returns (CoffeeResult) {} } //coffee.proto
->% curl -OL https://github.com/google/protobuf/releases/download/v3.5.0/ protobuf-java-3.5.0.tar.gz ->% tar -zxvf protobuf-java-3.5.0.tar.gz ->%
cd protobuf-3.5.0 ->% ./configure ->% make ->% sudo make install ->% protoc —version // -> libprotoc 3.5.0 :) //protoc
->% git clone
[email protected]
:grpc/grpc-java.git ->% cd grpc-java ->% git checkout
-b v1.7.0 ->% cd compiler ->% make ->% ../gradlew java_pluginExecutable ->% cp build/exe/java_plugin/protoc-gen-grpc-java /usr/local/bin //protoc-gen-grpc-java
->% protoc coffee.proto --grpc-java_out=lite:. --java_out=. --plugin=protoc-gen- grpc-java=/usr/local/bin/protoc-gen-grpc-java //generate proto files
for client ->% protoc --go_out=plugins=grpc:. coffee.proto //generate proto files for server Generate Proto Files
Generate Proto Files
gRPC on Android classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.2' implementation "io.grpc:grpc-okhttp:1.7.0" implementation "io.grpc:grpc-protobuf:1.7.0" implementation
"io.grpc:grpc-stub:1.7.0" implementation "javax.annotation:javax.annotation-api:1.2" //build.gradle //app/build.gradle
gRPC on Android val channel = ManagedChannelBuilder.forAddress("10.0.2.2", 8080) .usePlaintext(true) .build()
val stub = CoffeeGrpc.newBlockingStub(channel) val request = CoffeeOuterClass.CoffeeRequest.newBuilder() .setName(“hot coffee") .build() Single .create<CoffeeOuterClass.CoffeeResponse> { it.onSuccess(stub.order(request)) }.subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe( { /** do something */ }, { /** error handling */ } )
gRPC on Android val channel = ManagedChannelBuilder.forAddress("10.0.2.2", 8080) .usePlaintext(true) .build()
val stub = CoffeeGrpc.newBlockingStub(channel) val request = CoffeeOuterClass.CoffeeRequest.newBuilder() .setName(“hot coffee") .build() Single .create<CoffeeOuterClass.CoffeeResponse> { it.onSuccess(stub.order(request)) }.subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe( { /** do something */ }, { /** error handling */ } )
gRPC on Android val channel = ManagedChannelBuilder.forAddress("10.0.2.2", 8080) .usePlaintext(true) .build()
val stub = CoffeeGrpc.newBlockingStub(channel) val request = CoffeeOuterClass.CoffeeRequest.newBuilder() .setName(“hot coffee") .build() Single .create<CoffeeOuterClass.CoffeeResponse> { it.onSuccess(stub.order(request)) }.subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe( { /** do something */ }, { /** error handling */ } )
gRPC on Android val channel = ManagedChannelBuilder.forAddress("10.0.2.2", 8080) .usePlaintext(true) .build()
val stub = CoffeeGrpc.newBlockingStub(channel) val request = CoffeeOuterClass.CoffeeRequest.newBuilder() .setName(“hot coffee") .build() Single .create<CoffeeOuterClass.CoffeeResponse> { it.onSuccess(stub.order(request)) }.subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe( { /** do something */ }, { /** error handling */ } )
Demo
gRPC on Android https://github.com/takusemba https://twitter.com/takusemba