欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  移动技术

Android studio Kotlin中配置GRPC和protobuf时出现的一些问题总结

程序员文章站 2023-03-31 15:10:45
android studio kotlin中配置grpc和protobuf时出现的一些问题总结 kotlin中配置 grpc和protobuf 出现一些问题总结如下: 3rd-party gradl...

android studio kotlin中配置grpc和protobuf时出现的一些问题总结

kotlin中配置 grpc和protobuf 出现一些问题总结如下:

3rd-party gradle plug-ins may be the cause

codegen plugin grpc not defined

execution failed for task ‘:app:generatedebugproto’. > codegen plugin javalite not defined

io.grpc.statusruntimeexception: unimplemented: method not found


android studio运行不起来首先要找到打印出来的日志

1. 出现log信息

Android studio Kotlin中配置GRPC和protobuf时出现的一些问题总结

2. 查看详细log信息

Android studio Kotlin中配置GRPC和protobuf时出现的一些问题总结


看看第一个问题

3rd-party gradle plug-ins may be the cause

the com.google.protobuf plugin was already applied to the project: :app and will not be applied again after plugin: android
usenewcruncher has been deprecated. it will be removed in a future version of the gradle plugin. new cruncher is now always enabled.

configure successful in 0s

Android studio Kotlin中配置GRPC和protobuf时出现的一些问题总结

第二个问题

codegen plugin grpc not defined

executing tasks: [:app:generatedebugsources]

configuration on demand is an incubating feature.
the com.google.protobuf plugin was already applied to the project: :app and will not be applied again after plugin: android
usenewcruncher has been deprecated. it will be removed in a future version of the gradle plugin. new cruncher is now always enabled.
:app:prebuild up-to-date
:app:predebugbuild up-to-date
:app:compiledebugaidl up-to-date
:app:compiledebugrenderscript up-to-date
:app:checkdebugmanifest up-to-date
:app:generatedebugbuildconfig up-to-date
:app:extractdebugproto up-to-date
:app:extractincludedebugproto up-to-date
:app:extractproto up-to-date
:app:generatedebugproto
a problem was found with the configuration of task ':app:generatedebugproto'. registering invalid inputs and outputs via taskinputs and taskoutputs methods has been deprecated and is scheduled to be removed in gradle 5.0.
 - directory '/volumes/document/mt5/flashlight/app/build/extracted-include-protos/main' specified for property '$3' does not exist.
:app:generatedebugproto failed

failure: build failed with an exception.

* what went wrong:
execution failed for task ':app:generatedebugproto'.
> codegen plugin grpc not defined

* try:
run with --stacktrace option to get the stack trace. run with --info or --debug option to get more log output. run with --scan to get full insights.

* get more help at https://help.gradle.org

build failed in 0s
9 actionable tasks: 1 executed, 8 up-to-date

Android studio Kotlin中配置GRPC和protobuf时出现的一些问题总结

如下

//https://github.com/rouzwawi/grpc-kotlin
protobuf {
 protoc { artifact = 'com.google.protobuf:protoc:3.5.1-1' }
 plugins {
  javalite { artifact = "com.google.protobuf:protoc-gen-javalite:3.0.0" }
  //增加grpc插件
  grpc { artifact = 'io.grpc:protoc-gen-grpc-java:1.13.1' // current_grpc_version
  }
 }
 generateprototasks {
  all().each { task ->
task.plugins {
 javalite {}
 grpc { // options added to --grpc_out
  option 'lite' }
}
  }
 }
}

第三个问题

client error: io.grpc.statusruntimeexception: unknown