csdcorp / speech_to_text

A Flutter plugin that exposes device specific text to speech recognition capability.
BSD 3-Clause "New" or "Revised" License
351 stars 218 forks source link

inCompatible with Honor 10 #24

Closed mohammadne closed 4 years ago

mohammadne commented 4 years ago

ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: PlatformException(error, Attempt to invoke virtual method 'java.lang.String android.content.Intent.resolveTypeIfNeeded(android.content.ContentResolver)' on a null object reference, null)

mohammadne commented 4 years ago

I faced this issue when running example project. Thanks

sowens-csd commented 4 years ago

What Android version and device type?

mohammadne commented 4 years ago

Android version : 29 Device : Honor 10

sowens-csd commented 4 years ago

When does this happen?

  1. as soon as the application starts
  2. after clicking the initialize button
  3. after clicking listen
  4. while listening
  5. when clicking stop or cancel
mohammadne commented 4 years ago

Hi sowens After clicking initialize button, I get platform exception. So the listening button is disabled and I can't press it.

mohammadne commented 4 years ago

I test it on another device (LG K30) and it was ok. so perhapse the plugin is incompatible with some devices like honor 10 . but Why ?

sowens-csd commented 4 years ago

That's a great question. Now that I know where the issue is I'm going to add some more debugging output and see if I can localize it. Unfortunately I don't have an Honor 10 device and can't reproduce on the devices I do have. Would you mind running a test build on the Honor 10 for me and sending me the output?

sowens-csd commented 4 years ago

I've just committed an update to the Android code that logs each stage of the init process. If you have time could you do a build against the master branch of the repo and send me the logcat output? The section I'm looking for happens right after you click the Initialize button and should look like this:

D/SpeechToTextPlugin: Start initialize D/SpeechToTextPlugin: Checked permission has permission, completing completeInitialize Creating recognizer D/SpeechToTextPlugin: Setting listener before setup intent setupRecognizerIntent In RecognizerIntent apply put model put package put partial after setup intent sending result D/SpeechToTextPlugin: leaving complete leaving initializeIfPermitted

It also should print the stack trace of any exception, that should look like this, although the details will vary: E/SpeechToTextPlugin: Unexpected exception java.lang.IndexOutOfBoundsException: Index: 100, Size: 0 at java.util.ArrayList.get(ArrayList.java:437) at com.csdcorp.speech_to_text.SpeechToTextPlugin.onMethodCall(SpeechToTextPlugin.kt:82) at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:231) ...

I'd like the whole trace please.

mohammadne commented 4 years ago

excuse me for late response. I download speech_to_text: ^0.8.0 and run the example. but the logs you want , not appear. I still get an error like previous.

[ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: PlatformException(unknown, Unexpected exception, Attempt to invoke virtual method 'java.lang.String android.content.Intent.resolveTypeIfNeeded(android.content.ContentResolver)' on a null object reference)
E/flutter ( 2493): #0      StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:569:7)
E/flutter ( 2493): #1      MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:321:33)
E/flutter ( 2493): <asynchronous suspension>
E/flutter ( 2493): #2      SpeechToText.locales (package:speech_to_text/speech_to_text.dart:220:49)
E/flutter ( 2493): #3      _MyAppState.initSpeechState (package:speech_to_text_example/main.dart:36:35)
E/flutter ( 2493): <asynchronous suspension>
E/flutter ( 2493): #4      _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:706:14)
E/flutter ( 2493): #5      _InkResponseState.build.<anonymous closure> (package:flutter/src/material/ink_well.dart:789:36)
E/flutter ( 2493): #6      GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:182:24)
E/flutter ( 2493): #7      TapGestureRecognizer.handleTapUp (package:flutter/src/gestures/tap.dart:486:11)
E/flutter ( 2493): #8      BaseTapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:264:5)
E/flutter ( 2493): #9      BaseTapGestureRecognizer.handlePrimaryPointer (package:flutter/src/gestures/tap.dart:199:7)
E/flutter ( 2493): #10     PrimaryPointerGestureRecognizer.handleEvent (package:flutter/src/gestures/recognizer.dart:467:9)
E/flutter ( 2493): #11     PointerRouter._dispatch (package:flutter/src/gestures/pointer_router.dart:76:12)
E/flutter ( 2493): #12     PointerRouter._dispatchEventToRoutes.<anonymous closure> (package:flutter/src/gestures/pointer_router.dart:117:9)
E/flutter ( 2493): #13     _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:379:8)
E/flutter ( 2493): #14     PointerRouter._dispatchEventToRoutes (package:flutter/src/gestures/pointer_router.dart:115:18)
E/flutter ( 2493): #15     PointerRouter.route (package:flutter/src/gestures/pointer_router.dart:101:7)
E/flutter ( 2493): #16     GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:218:19)
E/flutter ( 2493): #17     GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:198:22)
E/flutter ( 2493): #18     GestureBinding._handlePointerEvent (package:flutter/src/gestures/binding.dart:156:7)
E/flutter ( 2493): #19     GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:102:7)
E/flutter ( 2493): #20     GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:86:7)
E/flutter ( 2493): #21     _rootRunUnary (dart:async/zone.dart:1138:13)
E/flutter ( 2493): #22     _CustomZone.runUnary (dart:async/zone.dart:1031:19)
E/flutter ( 2493): #23     _CustomZone.runUnaryGuarded (dart:async/zone.dart:933:7)
E/flutter ( 2493): #24     _invoke1 (dart:ui/hooks.dart:273:10)
E/flutter ( 2493): #25     _dispatchPointerDataPacket (dart:ui/hooks.dart:182:5)
sowens-csd commented 4 years ago

That's very helpful, thanks! Something is going wrong trying to get the locales. I'll have a look at that now.

sowens-csd commented 4 years ago

You might get more information if you ran it in Android Studio or watched the logs through logcat as you ran the app. https://developer.android.com/studio/command-line/logcat

sowens-csd commented 4 years ago

Given where that exception is you could work around it by not calling locales and not providing a particular locale in the listen method. It might be worth trying to see if the rest of the functionality is working on that device.

I just pushed a small change to the locales method that does some more error checking when retrieving the intent from Android. It's one possible place where the null error could be coming from. You'll need to refer directly to the git repo to see that change.

sowens-csd commented 4 years ago

Were you able to try the new version?

sowens-csd commented 4 years ago

I'm going to close this until new info comes in. I've tested the example app on SDK 29 on a Pixel 3a (emulator) and it's working. There may well be an issue with the Honor 10 device but if so I'll need more input. If you have any further comments please don't hesitate to reopen.

mohammadne commented 4 years ago

Restarted application in 1,467ms. V/AudioManager( 6709): playSoundEffect effectType: 0 V/AudioManager( 6709): querySoundEffectsEnabled... D/SpeechToTextPlugin( 6709): Start initialize D/SpeechToTextPlugin( 6709): Checked permission D/SpeechToTextPlugin( 6709): has permission, completing D/SpeechToTextPlugin( 6709): completeInitialize D/SpeechToTextPlugin( 6709): Creating recognizer D/SpeechToTextPlugin( 6709): Setting listener D/SpeechToTextPlugin( 6709): before setup intent D/SpeechToTextPlugin( 6709): setupRecognizerIntent D/SpeechToTextPlugin( 6709): In RecognizerIntent apply D/SpeechToTextPlugin( 6709): put model D/SpeechToTextPlugin( 6709): put package D/SpeechToTextPlugin( 6709): put partial D/SpeechToTextPlugin( 6709): after setup intent D/SpeechToTextPlugin( 6709): sending result D/SpeechToTextPlugin( 6709): leaving complete D/SpeechToTextPlugin( 6709): leaving initializeIfPermitted

sowens-csd commented 4 years ago

Did that trace happen just before a platform exception? Or is this a successful run?

mohammadne commented 4 years ago

there was no any trace. and I am sure this is a bug only on my device(Honor 10) what can I do ?

sowens-csd commented 4 years ago

So you're still seeing the PlatformException that you reported above? And the log that you posted earlier today is from a run where that PlatformException happens?

And you've tried it with the version from GitHub that has the change I made?

mohammadne commented 4 years ago

the PlatFormException is gone and I don't see it again. I tested some other apps from play-store but also they didn't work. I am sure there is a bug on Honor 10.

sowens-csd commented 4 years ago

Thanks for letting me know.