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
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
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コーディングの環境改善を加速した
shoota
1
250
AIが自律的に回る開発ループを設計してチーム開発に組み込む
nekorush14
0
110
現場のトークンマネジメント
dak2
1
160
データサイエンスを価値につなげるプロジェクト設計 〜 DS一年目が現場で得た気づき 〜
ysd113
1
290
AIのReact習熟度を測る
uhyo
2
660
生成 AI 実践ガイド (概略版) AIガバナンス編
asei
0
150
自宅LLMの話
jacopen
1
700
手塩にかけりゃいいってもんじゃない
ming_ayami
0
620
Oracle AI Database@Google Cloud:サービス概要のご紹介
oracle4engineer
PRO
6
1.6k
Kiroで書いた 設計書 が AI レビューの 採点基準 になる
ezaki
0
140
SteampipeとExcel Power QueryでAWS構成定義書の作成を自動化する
jhashimoto
0
170
ACE-Step-1.5で見る 音楽生成AIのしくみと“破綻だけ直す”Retake機能の開発【zennfes spring 2026 登壇資料】
personabb
1
550
Featured
See All Featured
Taking LLMs out of the black box: A practical guide to human-in-the-loop distillation
inesmontani
PRO
3
2.3k
Leveraging LLMs for student feedback in introductory data science courses - posit::conf(2025)
minecr
1
290
Agile Leadership in an Agile Organization
kimpetersen
PRO
0
170
Raft: Consensus for Rubyists
vanstee
141
7.5k
A designer walks into a library…
pauljervisheath
211
24k
SEO in 2025: How to Prepare for the Future of Search
ipullrank
3
3.5k
Future Trends and Review - Lecture 12 - Web Technologies (1019888BNR)
signer
PRO
0
3.6k
GitHub's CSS Performance
jonrohan
1033
470k
How STYLIGHT went responsive
nonsquared
100
6.2k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3.5k
The innovator’s Mindset - Leading Through an Era of Exponential Change - McGill University 2025
jdejongh
PRO
1
200
How Fast Is Fast Enough? [PerfNow 2025]
tammyeverts
3
610
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