plyer 03-18 22:14:31.922 11532 11532 E SpeechRecognizer: not connected to the recognition service

178 views
Skip to first unread message

alessandro bonvicini

unread,
Mar 18, 2021, 5:47:29 PM3/18/21
to Kivy users support
Hello  everybody ,
i m trying to make the
exmple work on my android 10 huaway phone

i receive the error in the  subject

in buildozer my permissions is set to
android.permissions = INTERNET, ACCESS_NETWORK_STATE, VIBRATE, RECORD_AUDIO, READ_EXTERNAL_STORAGE, WRITE_EXTERNAL_STORAGE

and the reuirements are
requirements = python3,kivy,plyer,SpeechRecognition,android
i granted manually permissions on my apk microphone and storage.

No one error arise form the log except for the one in subject  and the followings that are relevant, i think

PLEase may you help me to understand whats happening and to find a solution?
I really really need this piece of code working ...i am trying to demonstrate that kivy is a really productive technology in respect to java and others so for my target this way to simplify the access to java runtime si crucial
Thank  you a lot in advance


------------------------------------------------------------------------------------------------------------------------------------

03-18 22:38:44.860  4384  4384 I A       : RecognitionService#onStartListening
03-18 22:38:44.861  4384  4384 W Bundle  : Key calling_package expected String but value was a [C.  The default value <null> was returned.
03-18 22:38:44.861  1473  4839 W ProcBatteryStats: timer is not running , not stop, name: com.huawei.android.totemweather, uid: 10040, tag: *location*
03-18 22:38:44.861  4384  4384 W Bundle  : Attempt to cast generated internal exception:
03-18 22:38:44.861  4384  4384 W Bundle  : java.lang.ClassCastException: char[] cannot be cast to java.lang.String
03-18 22:38:44.861  4384  4384 W Bundle  :     at android.os.BaseBundle.getString(BaseBundle.java:1167)
03-18 22:38:44.861  4384  4384 W Bundle  :     at android.content.Intent.getStringExtra(Intent.java:8058)
03-18 22:38:44.861  4384  4384 W Bundle  :     at com.google.android.apps.search.transcription.g.e.j.a(SourceFile:3)
03-18 22:38:44.861  4384  4384 W Bundle  :     at com.google.android.apps.search.transcription.g.e.i.a(SourceFile:3)
03-18 22:38:44.861  4384  4384 W Bundle  :     at com.google.android.voicesearch.serviceapi.GoogleRecognitionService.onStartListening(SourceFile:7)
03-18 22:38:44.861  4384  4384 W Bundle  :     at android.speech.RecognitionService.dispatchStartListening(RecognitionService.java:113)
03-18 22:38:44.861  4384  4384 W Bundle  :     at android.speech.RecognitionService.access$000(RecognitionService.java:39)
03-18 22:38:44.861  4384  4384 W Bundle  :     at android.speech.RecognitionService$1.handleMessage(RecognitionService.java:82)
03-18 22:38:44.861  4384  4384 W Bundle  :     at android.os.Handler.dispatchMessage(Handler.java:107)
03-18 22:38:44.861  4384  4384 W Bundle  :     at android.os.Looper.loop(Looper.java:213)
03-18 22:38:44.861  4384  4384 W Bundle  :     at android.app.ActivityThread.main(ActivityThread.java:8178)
03-18 22:38:44.861  4384  4384 W Bundle  :     at java.lang.reflect.Method.invoke(Native Method)
03-18 22:38:44.861  4384  4384 W Bundle  :     at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:513)
03-18 22:38:44.861  4384  4384 W Bundle  :     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1101)
03-18 22:38:44.862  4384  4384 I A       : Using Locale.getDefault() for recognition: null
03-18 22:38:44.862  1473  4839 I LocationManagerService: requestingHighPowerLocation = false
03-18 22:38:44.863  4384  4384 W Bundle  : Key calling_package expected String but value was a [C.  The default value <null> was returned.
03-18 22:38:44.863  4384  4384 W Bundle  : Attempt to cast generated internal exception:
03-18 22:38:44.863  4384  4384 W Bundle  : java.lang.ClassCastException: char[] cannot be cast to java.lang.String
03-18 22:38:44.863  4384  4384 W Bundle  :     at android.os.BaseBundle.getString(BaseBundle.java:1167)
03-18 22:38:44.863  4384  4384 W Bundle  :     at android.content.Intent.getStringExtra(Intent.java:8058)
03-18 22:38:44.863  4384  4384 W Bundle  :     at com.google.android.apps.search.transcription.g.e.j.a(SourceFile:3)
03-18 22:38:44.863  4384  4384 W Bundle  :     at com.google.android.apps.search.transcription.g.e.i.a(SourceFile:19)
03-18 22:38:44.863  4384  4384 W Bundle  :     at com.google.android.voicesearch.serviceapi.GoogleRecognitionService.onStartListening(SourceFile:7)
03-18 22:38:44.863  4384  4384 W Bundle  :     at android.speech.RecognitionService.dispatchStartListening(RecognitionService.java:113)
03-18 22:38:44.863  4384  4384 W Bundle  :     at android.speech.RecognitionService.access$000(RecognitionService.java:39)
03-18 22:38:44.863  4384  4384 W Bundle  :     at android.speech.RecognitionService$1.handleMessage(RecognitionService.java:82)
03-18 22:38:44.863  4384  4384 W Bundle  :     at android.os.Handler.dispatchMessage(Handler.java:107)
03-18 22:38:44.863  4384  4384 W Bundle  :     at android.os.Looper.loop(Looper.java:213)
03-18 22:38:44.863  4384  4384 W Bundle  :     at android.app.ActivityThread.main(ActivityThread.java:8178)
03-18 22:38:44.863  4384  4384 W Bundle  :     at java.lang.reflect.Method.invoke(Native Method)
03-18 22:38:44.863  4384  4384 W Bundle  :     at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:513)
03-18 22:38:44.863  4384  4384 W Bundle  :     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1101)
03-18 22:38:44.864  4384  4384 E A       : Error parsing intent: EXTRA_PREFER_OFFLINE parameter is deprecated.
03-18 22:38:44.866  2258  2468 D DeviceMonitor: GPS request stop:com.huawei.android.totemweather pid:2308 interval(s): -1 reqId:b241c06
03-18 22:38:44.875  2222 12396 I GCoreUlr: Successfully inserted 1 locations
03-18 22:38:44.876  4384 12238 W Binder  : Caught a RuntimeException from the binder stub implementation.
03-18 22:38:44.876  4384 12238 W Binder  : java.lang.SecurityException: uid 10125 does not have android.permission.UPDATE_APP_OPS_STATS.
03-18 22:38:44.876  4384 12238 W Binder  :     at android.os.Parcel.createException(Parcel.java:2071)
03-18 22:38:44.876  4384 12238 W Binder  :     at android.os.Parcel.readException(Parcel.java:2039)
03-18 22:38:44.876  4384 12238 W Binder  :     at android.os.Parcel.readException(Parcel.java:1987)
03-18 22:38:44.876  4384 12238 W Binder  :     at com.android.internal.app.IAppOpsService$Stub$Proxy.checkOperationRaw(IAppOpsService.java:1617)
03-18 22:38:44.876  4384 12238 W Binder  :     at android.app.AppOpsManager.unsafeCheckOpRawNoThrow(AppOpsManager.java:5004)
03-18 22:38:44.876  4384 12238 W Binder  :     at android.content.PermissionChecker.checkPermissionCommon(PermissionChecker.java:402)
03-18 22:38:44.876  4384 12238 W Binder  :     at android.content.PermissionChecker.checkPermissionForPreflight(PermissionChecker.java:162)
03-18 22:38:44.876  4384 12238 W Binder  :     at android.content.PermissionChecker.checkCallingOrSelfPermissionForPreflight(PermissionChecker.java:372)
03-18 22:38:44.876  4384 12238 W Binder  :     at android.speech.RecognitionService.checkPermissions(RecognitionService.java:185)
03-18 22:38:44.876  4384 12238 W Binder  :     at android.speech.RecognitionService.access$700(RecognitionService.java:39)
03-18 22:38:44.876  4384 12238 W Binder  :     at android.speech.RecognitionService$RecognitionServiceBinder.cancel(RecognitionService.java:376)
03-18 22:38:44.876  4384 12238 W Binder  :     at android.speech.IRecognitionService$Stub.onTransact(IRecognitionService.java:149)
03-18 22:38:44.876  4384 12238 W Binder  :     at android.os.Binder.execTransactInternal(Binder.java:1028)
03-18 22:38:44.876  4384 12238 W Binder  :     at android.os.Binder.execTransact(Binder.java:1001)
03-18 22:38:44.876  4384 12238 W Binder  : Caused by: android.os.RemoteException: Remote stack trace:
03-18 22:38:44.876  4384 12238 W Binder  :     at android.app.ContextImpl.enforce(ContextImpl.java:2001)
03-18 22:38:44.876  4384 12238 W Binder  :     at android.app.ContextImpl.enforcePermission(ContextImpl.java:2010)
03-18 22:38:44.876  4384 12238 W Binder  :     at com.android.server.appop.AppOpsService.verifyIncomingUid(AppOpsService.java:2470)
03-18 22:38:44.876  4384 12238 W Binder  :     at com.android.server.appop.AppOpsService.checkOperationImpl(AppOpsService.java:1828)
03-18 22:38:44.876  4384 12238 W Binder  :     at com.android.server.appop.AppOpsService.checkOperationInternal(AppOpsService.java:1820)
03-18 22:38:44.876  4384 12238 W Binder  :
03-18 22:38:44.879  1473  1717 W ProcBatteryStats: timer is not running , not stop, name: com.google.android.gms, uid: 10120, tag: *location*
03-18 22:38:44.880  4384  4384 I A       : RecognitionService#onDestroy
03-18 22:38:44.881 11532 11532 E SpeechRecognizer: not connected to the recognition service

---------------------------------------------------------------------------------------------------------------------------------------------------


alessandro bonvicini

unread,
Mar 18, 2021, 5:55:36 PM3/18/21
to Kivy users support
Adding thsi
03-18 22:48:24.197  4384  7224 E RecognitionService: call for recognition service without RECORD_AUDIO permissions
03-18 22:48:24.198  4384  4384 I A       : RecognitionService#onDestroy


i found the row above in the log  BUT i have RECORD_AUDIO set in my buildozer.spec.

Is this one a bug ? please help me.

Robert

unread,
Mar 18, 2021, 7:42:21 PM3/18/21
to Kivy users support
PLEase may you help me to understand whats happening and to find a solution?

The permissions and requirements look like you are desperately guessing. Which is unlikely to work.
The approach that works is debugging using analysis.

I tried with the supplied buildozer.spec (changing kivy to kivy==2.0.0) and adding run time RECORD_AUDIO permission in main.py.
(the need to do that is a hint of neglected software)
It didn't work on an Android 11 device or an Android 6 device.

The idea of Plyer is very appealing, but in practice it does not always deliver. Don't assume it works.

Pyjnius works great, I use that a lot - Python syntax and semantics with specific Java class semantics added.

Trying a test case was a good approach.
If it works great, if not decide how much time you want to spend fixing it yourself or walk away.

alessandro bonvicini

unread,
Mar 19, 2021, 4:40:55 AM3/19/21
to Kivy users support
Hi , you are absolutely right, i am not an expert in kivy or android programming so ,as you said, i just tried to guess.
But, i thank you  for your suggestions, i read that in andorid version > 8 yuo  have to set permission manually inside the runtime app.
I do not know how to do this from python , so an example is welcome. 

I'll try to approach  pyjinius....
tahnk you very much again 

alessandro bonvicini

unread,
Mar 19, 2021, 7:38:08 AM3/19/21
to Kivy users support
Hello,
regarding this problem i set up the permission in
def build(self):
        request_permissions([Permission.INTERNET,Permission.RECORD_AUDIO])
        self.title = 'Recording Application'

This time the error on permission went away but there is always the following exception  the destroy the recognition  service
Someone can help me?

Noting op not finished: uid 10125 pkg com.google.android.googlequicksearchbox code 27 time=1616153654077 duration=0
03-19 12:34:31.933  4384  4384 I A       : RecognitionService#onStartListening
03-19 12:34:31.933  4384  4384 W Bundle  : Key calling_package expected String but value was a [C.  The default value <null> was returned.
03-19 12:34:31.934  4384  4384 W Bundle  : Attempt to cast generated internal exception:
03-19 12:34:31.934  4384  4384 W Bundle  : java.lang.ClassCastException: char[] cannot be cast to java.lang.String
03-19 12:34:31.934  4384  4384 W Bundle  :     at android.os.BaseBundle.getString(BaseBundle.java:1167)
03-19 12:34:31.934  4384  4384 W Bundle  :     at android.content.Intent.getStringExtra(Intent.java:8058)
03-19 12:34:31.934  4384  4384 W Bundle  :     at com.google.android.apps.search.transcription.g.e.j.a(SourceFile:3)
03-19 12:34:31.934  4384  4384 W Bundle  :     at com.google.android.apps.search.transcription.g.e.i.a(SourceFile:3)
03-19 12:34:31.934  4384  4384 W Bundle  :     at com.google.android.voicesearch.serviceapi.GoogleRecognitionService.onStartListening(SourceFile:7)
03-19 12:34:31.934  4384  4384 W Bundle  :     at android.speech.RecognitionService.dispatchStartListening(RecognitionService.java:113)
03-19 12:34:31.934  4384  4384 W Bundle  :     at android.speech.RecognitionService.access$000(RecognitionService.java:39)
03-19 12:34:31.934  4384  4384 W Bundle  :     at android.speech.RecognitionService$1.handleMessage(RecognitionService.java:82)
03-19 12:34:31.934  4384  4384 W Bundle  :     at android.os.Handler.dispatchMessage(Handler.java:107)
03-19 12:34:31.934  4384  4384 W Bundle  :     at android.os.Looper.loop(Looper.java:213)
03-19 12:34:31.934  4384  4384 W Bundle  :     at android.app.ActivityThread.main(ActivityThread.java:8178)
03-19 12:34:31.934  4384  4384 W Bundle  :     at java.lang.reflect.Method.invoke(Native Method)
03-19 12:34:31.934  4384  4384 W Bundle  :     at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:513)
03-19 12:34:31.934  4384  4384 W Bundle  :     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1101)
03-19 12:34:31.934  4384  4384 I A       : Using Locale.getDefault() for recognition: null

Robert

unread,
Mar 19, 2021, 1:30:13 PM3/19/21
to Kivy users support
Pyjnius is certainly jumping in at the deep end of the swimming pool.

The message says an Intent.getStringExtra() call is being passed a character array, but the recipient expects a Java String.
It looks like this occurs when the RecognitionSevice Listener starts.
Seems a reasonable the char array is coming from Python.

Perhaps one or two of the putExtra() arguments needs a cast to java.lang.String ?
But, there is more research to do......

A quick look at the putExtra() documentation shows that it is heavily overloaded, and both String and char[] are legal.
So this would probably not be caught till run time.
But it there are other choices, Parcelable[], String[], or Bundle are also possibilities.
If you don't want to dig through the RecognitionService documentation, String seems like a good first try.


Unrelated, FYI, and not wrong:
INTERNET does not need to have a run time permission because it does not have a protection_level "dangerous"
Reply all
Reply to author
Forward
0 new messages