728x90
Android gRPC 통신을 위한 Client 구현을 위해서 google proto buf 및 proto file 빌드를 위한 gradle 설정이 필요하다.
1. gradle protobuf plugin 설정
apply plugin: 'com.google.protobuf'
2. protobuf build 환경 설정
buildscript{
repositories{
google()
mavenCentral()
}
dependencies{
classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.14'
}
}
protobuf {
protoc {
artifact = "com.google.protobuf:protoc:3.12.0"
// Set the location of generated source code by protoc compiler
generatedFilesBaseDir = "$projectDir/gen-src"
}
plugins {
grpc {
artifact = 'io.grpc:protoc-gen-grpc-java:1.32.1'
}
grpckt { artifact = 'io.grpc:protoc-gen-grpc-kotlin:1.0.0:jdk7@jar' }
}
generateProtoTasks {
all().each { task ->
task.builtins {
java { option 'lite' }
}
task.plugins {
grpc { // Options added to --grpc_out
option 'lite' }
}
}
}
}
3. protobuf 통신 및 proto class 참조를 위한 gradle 의존성 추가
implementation 'io.grpc:grpc-okhttp:1.38.1' // CURRENT_GRPC_VERSION
implementation 'io.grpc:grpc-protobuf-lite:1.38.1'
implementation 'io.grpc:grpc-stub:1.38.1'
implementation 'javax.annotation:javax.annotation-api:1.3.2'
728x90
'Android > gRPC' 카테고리의 다른 글
[M1/M2] Android gRPC 적용 가이드 (0) | 2024.04.26 |
---|---|
Android gRPC Client 구현(2) - Connection (0) | 2021.10.01 |