I made a simple protobuf+gRPC server/client example with Python, and wanted now to complete it with an Android Java client. However, I struggled through the documentation and got it mostly working (.proto compiles in Android Studio), BUT now I get Errors in the output *Grpc.java file (i.e. if I fix it it will just be overwritten by the compiler):
error: package io.grpc.protobuf does not exist
error: package com.google.protobuf.Descriptors does not exist
Since I get errors from io.gprc's and com.google's protobuf, I suspect a definition conflict in my gradle, but I cannot find/resolve it (went through several "tutorials" and it seemed common to use a mix of grpc and google sources).
Here is my build.gradle:
android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
defaultConfig {
applicationId "***.grpcclient"
minSdkVersion 21
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
implementation 'io.grpc:grpc-okhttp:1.25.0'
//implementation 'io.grpc:grpc-protobuf-lite:1.25.0'
implementation 'com.google.protobuf:protobuf-javalite:3.8.0'
implementation 'io.grpc:grpc-stub:1.25.0'
implementation 'org.glassfish:javax.annotation:10.0-b28'
}
apply plugin: 'com.google.protobuf'
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.10'
}
}
protobuf {
protoc {
artifact = 'com.google.protobuf:protoc:3.8.0'
}
plugins {
grpc {
artifact = 'io.grpc:protoc-gen-grpc-java:1.25.0'
}
}
generateProtoTasks {
all().each { task ->
task.builtins {
java {
option "lite"
}
python { }
}
task.plugins {
grpc {outputSubDir = 'java'}
}
}
}
}
Any help is appreciated!