GoogleCloudPlatform / android-docs-samples

Apache License 2.0
375 stars 596 forks source link

Speech-to-Text android app crashing #94

Open va26 opened 5 years ago

va26 commented 5 years ago

I am trying to use the Google Speech-to-Text API given here. I built a signed apk but when I run it on the device it crashes. I checked the logs and this is what I get :

    --------- beginning of crash
02-12 12:35:22.504 29178 29178 E AndroidRuntime: FATAL EXCEPTION: main
02-12 12:35:22.504 29178 29178 E AndroidRuntime: Process: com.google.cloud.examples.speechrecognition, PID: 29178
02-12 12:35:22.504 29178 29178 E AndroidRuntime: java.lang.NoSuchMethodError: No static method decodeBase64(Ljava/lang/String;)[B in class Lorg/apache/commons/codec/binary/Base64; or its super classes (declaration of 'org.apache.commons.codec.binary.Base64' appears in /system/framework/org.apache.http.legacy.boot.jar)
02-12 12:35:22.504 29178 29178 E AndroidRuntime:    at com.google.api.client.util.Base64.decodeBase64(Base64.java:101)
02-12 12:35:22.504 29178 29178 E AndroidRuntime:    at com.google.api.client.util.PemReader.readNextSection(PemReader.java:106)
02-12 12:35:22.504 29178 29178 E AndroidRuntime:    at com.google.api.client.util.PemReader.readFirstSectionAndClose(PemReader.java:135)
02-12 12:35:22.504 29178 29178 E AndroidRuntime:    at com.google.auth.oauth2.ServiceAccountCredentials.privateKeyFromPkcs8(ServiceAccountCredentials.java:296)
02-12 12:35:22.504 29178 29178 E AndroidRuntime:    at com.google.auth.oauth2.ServiceAccountCredentials.fromPkcs8(ServiceAccountCredentials.java:286)
02-12 12:35:22.504 29178 29178 E AndroidRuntime:    at com.google.auth.oauth2.ServiceAccountCredentials.fromJson(ServiceAccountCredentials.java:210)
02-12 12:35:22.504 29178 29178 E AndroidRuntime:    at com.google.auth.oauth2.GoogleCredentials.fromStream(GoogleCredentials.java:174)
02-12 12:35:22.504 29178 29178 E AndroidRuntime:    at com.google.auth.oauth2.GoogleCredentials.fromStream(GoogleCredentials.java:141)
02-12 12:35:22.504 29178 29178 E AndroidRuntime:    at com.google.cloud.examples.speechrecognition.MainActivity$mSpeechClient$2$1$1.getCredentials(MainActivity.kt:62)
02-12 12:35:22.504 29178 29178 E AndroidRuntime:    at com.google.cloud.examples.speechrecognition.MainActivity$mSpeechClient$2$1$1.getCredentials(MainActivity.kt:45)
02-12 12:35:22.504 29178 29178 E AndroidRuntime:    at com.google.api.gax.rpc.ClientContext.create(ClientContext.java:140)
02-12 12:35:22.504 29178 29178 E AndroidRuntime:    at com.google.cloud.speech.v1.stub.GrpcSpeechStub.create(GrpcSpeechStub.java:94)
02-12 12:35:22.504 29178 29178 E AndroidRuntime:    at com.google.cloud.speech.v1.stub.SpeechStubSettings.createStub(SpeechStubSettings.java:126)
02-12 12:35:22.504 29178 29178 E AndroidRuntime:    at com.google.cloud.speech.v1.SpeechClient.<init>(SpeechClient.java:144)
02-12 12:35:22.504 29178 29178 E AndroidRuntime:    at com.google.cloud.speech.v1.SpeechClient.create(SpeechClient.java:126)
02-12 12:35:22.504 29178 29178 E AndroidRuntime:    at com.google.cloud.examples.speechrecognition.MainActivity$mSpeechClient$2.invoke(MainActivity.kt:61)
02-12 12:35:22.504 29178 29178 E AndroidRuntime:    at com.google.cloud.examples.speechrecognition.MainActivity$mSpeechClient$2.invoke(MainActivity.kt:45)
02-12 12:35:22.504 29178 29178 E AndroidRuntime:    at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74)
02-12 12:35:22.504 29178 29178 E AndroidRuntime:    at com.google.cloud.examples.speechrecognition.MainActivity.getMSpeechClient(Unknown Source:7)
02-12 12:35:22.504 29178 29178 E AndroidRuntime:    at com.google.cloud.examples.speechrecognition.MainActivity.onResume(MainActivity.kt:101)
02-12 12:35:22.504 29178 29178 E AndroidRuntime:    at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1363)
02-12 12:35:22.504 29178 29178 E AndroidRuntime:    at android.app.Activity.performResume(Activity.java:7444)
02-12 12:35:22.504 29178 29178 E AndroidRuntime:    at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3805)
02-12 12:35:22.504 29178 29178 E AndroidRuntime:    at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3870)
02-12 12:35:22.504 29178 29178 E AndroidRuntime:    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1788)
02-12 12:35:22.504 29178 29178 E AndroidRuntime:    at android.os.Handler.dispatchMessage(Handler.java:106)
02-12 12:35:22.504 29178 29178 E AndroidRuntime:    at android.os.Looper.loop(Looper.java:164)
02-12 12:35:22.504 29178 29178 E AndroidRuntime:    at android.app.ActivityThread.main(ActivityThread.java:7036)
02-12 12:35:22.504 29178 29178 E AndroidRuntime:    at java.lang.reflect.Method.invoke(Native Method)
02-12 12:35:22.504 29178 29178 E AndroidRuntime:    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:441)
02-12 12:35:22.504 29178 29178 E AndroidRuntime:    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1408)

Please help me resolve this. Thank you.