android studio Kotlin中使用 GRPC和protobuf 出现一些问题总结
程序员文章站
2022-03-26 11:29:38
...
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 definedio.grpc.StatusRuntimeException: UNIMPLEMENTED: Method not found
android studio运行不起来首先要找到打印出来的日志
1. 出现log信息
2. 查看详细Log信息
看看第一个问题
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
第二个问题
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
源码如下
//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