0

I try to compile proto definitions into kotlin stubs, but get import issues. My gradle is


protobuf {
    protoc {
        artifact = "com.google.protobuf:protoc:3.21.2"
    }

    plugins {
        grpckt {
            artifact = "io.grpc:protoc-gen-grpc-kotlin:1.3.0:jdk8@jar"
        }
    }

    generateProtoTasks {
        all().forEach { task ->
            task.builtins {
                grpckt {
                    option 'lite'
                }
            }
            task.plugins {
                kotlin {
                    option 'lite'
                }
            }
        }
    }
}

dependencies {

    //grpc dependency
    implementation("io.grpc:grpc-kotlin-stub:1.3.0")
    implementation 'io.grpc:grpc-okhttp:1.47.0'
    implementation("io.grpc:grpc-protobuf:1.47.0")
    implementation("com.google.protobuf:protobuf-kotlin:3.21.12")
    implementation 'io.grpc:grpc-protobuf-lite:1.47.0'

}

I have few proto files. After proto compiled I get the files with import errors: enter image description here

option java_multiple_files = true - doesn`t help.

Andreas
  • 51
  • 1
  • 5

1 Answers1

0

You are configuring your proto generation in lite mode but not using the kotlin-lite library. That may be causing your issues.

Try replacing

implementation("com.google.protobuf:protobuf-kotlin:3.21.12")

with

implementation("com.google.protobuf:protobuf-kotlin-lite:3.21.12")
Alejandro Lorefice
  • 797
  • 1
  • 5
  • 18