GoogleCloudPlatform / android-docs-samples

Apache License 2.0
375 stars 596 forks source link

protobuf build failures #130

Open KevinQuinnMT opened 2 years ago

KevinQuinnMT commented 2 years ago

Hello,

The short version is, would it be possible to rebuild the speech, and specifically streaming speech projects so they do not currently fail. Currently these samples are non functional because of changes to the android ecosystem.

The longer version is:

I have created a voice solution heavily based on the speech to text examples found in this repository. It has been working in a production environment for a while, but recently it has encountered crashing in newer android devices. The crashing seems to be related to

https://github.com/grpc/grpc-java/commit/5803dfd9dcca0fba4483fccf724efc1c853a3ada

however attempting to rebuild protobuf results in this error

This seems to be related to https://stackoverflow.com/questions/59606918/cloud-speech-v1-streamingrecognizeresponse-error-an-enum-switch-case-label-mu

Which is referencing this ( https://github.com/GoogleCloudPlatform/android-docs-samples ) repository.

i was able to get the above error to resolve by making the following changes:

buildscript {

...

dependencies {

    classpath 'com.android.tools.build:gradle:3.5.3'

    classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.8' <-- TO --> classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.17'

}

}

ext {

grpcVersion = '1.4.0' <-- TO --> grpcVersion = '1.39.0'

}

android {

compileSdkVersion 28 <-- TO --> 30

buildToolsVersion '28.0.0' <-- TO --> '29.0.3'

defaultConfig {

    minSdkVersion 16 <-- TO --> 23

    targetSdkVersion 28 <-- TO --> 30

    <-- ADD -- > compileSdkVersion 30

    ...

}

}

dependencies {

implementation "io.grpc:grpc-okhttp:$grpcVersion"

implementation "io.grpc:grpc-protobuf-lite:$grpcVersion"

implementation "io.grpc:grpc-stub:$grpcVersion"

implementation 'javax.annotation:javax.annotation-api:1.2'  <-- TO -->  implementation 'javax.annotation:javax.annotation-api:1.3.2'

protobuf 'com.google.protobuf:protobuf-java:3.3.1' <-- TO --> protobuf 'com.google.protobuf:protobuf-java:3.17.3'

...

}

protobuf {

protoc {

    artifact = 'com.google.protobuf:protoc:3.3.0' <-- TO --> artifact = 'com.google.protobuf:protoc:3.17.3'

}

however these new versions have their own problems -

new Error after updating a number of various build.gradle plugins and repository versions

Execution failed for task ':generateDebugProto'.

protoc: stdout: . stderr: C:\Users\KQUINN\Programming\Node.js\React-Native\Meditech\mob_library_react_native_voice\src\android\build\extracted-protos\main\google\protobuf\any.proto: Input is shadowed in the --proto_path by "C:/Users/KQUINN/Programming/Node.js/React-Native/Meditech/mob_library_react_native_voice/src/android/build/extracted-include-protos/debug/google/protobuf/any.proto". Either use the latter file as your input or reorder the --proto_path so that the former file's location comes first.

This last problem seems to be what is exactly described in https://github.com/grpc-ecosystem/polyglot/issues/110

If it is possible to update the samples that would be very helpful, as it could be used as a basis to update my own project. As it stands I only have a cursory understanding of protobuf files and the protobuf compilation process, so any assistance towards resolving protobuf compilation errors would be appreciated!

Thank You, Kevin

HQTracy commented 2 years ago

I also encountered the same problem, did you solve it, thank you very much!