speech-and-text-unity-ios-android icon indicating copy to clipboard operation
speech-and-text-unity-ios-android copied to clipboard

Not working on Android 11

Open deadlyghost753 opened this issue 4 years ago • 16 comments

Hi, thanks for your great plugin. It working great on androids under 11, but it not working on android 11. Can you help me to fix this on android 11?

deadlyghost753 avatar Jul 12 '21 17:07 deadlyghost753

Hi, same problem here. In my case, I actually observed this problem on some phones with Android 10, either. Have you found any solution?

denyslave avatar Jul 22 '21 13:07 denyslave

Same problem here. Just updated to Android 11. Seems like the MainActivity class is missing? Here's a snapshot of the Android Logcat error that I'm getting at least.

image

joepeaden avatar Aug 16 '21 23:08 joepeaden

Hey, I could actually found the solution in this thread: https://stackoverflow.com/questions/45992420/speechrecognizer-bind-to-recognition-service-failed

Just add this lines to your unityLibrary/manifests/AndroidManifest.xml: <queries> <package android:name="com.google.android.googlequicksearchbox"/> </queries>

denyslave avatar Aug 17 '21 11:08 denyslave

The update needed is in \SpeechToText_AppleAPI\Assets\Plugins\Android\AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
          package="com.starseed.speechtotext" 
		  android:versionCode="1" android:versionName="1.0">
  <uses-permission android:name="android.permission.RECORD_AUDIO" />
  <uses-permission android:name="android.permission.INTERNET" />
  <uses-sdk android:minSdkVersion="16" android:targetSdkVersion="23" />
    <queries>
        <package android:name="com.google.android.googlequicksearchbox"/>
    </queries>
    <application 
    android:icon="@drawable/app_icon" 
    android:label="@string/app_name" android:debuggable="false"
    android:configChanges="orientation|screenSize|locale"
    android:theme="@style/UnityThemeSelector">
    <activity 
      android:name="com.starseed.speechtotext.MainActivity" 
	    android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
      android:label="@string/app_name">
      <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
      </intent-filter>
    </activity>   
  </application>
</manifest>

riesvriend avatar Aug 31 '21 14:08 riesvriend

The update needed is in \SpeechToText_AppleAPI\Assets\Plugins\Android\AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
          package="com.starseed.speechtotext" 
		  android:versionCode="1" android:versionName="1.0">
  <uses-permission android:name="android.permission.RECORD_AUDIO" />
  <uses-permission android:name="android.permission.INTERNET" />
  <uses-sdk android:minSdkVersion="16" android:targetSdkVersion="23" />
    <queries>
        <package android:name="com.google.android.googlequicksearchbox"/>
    </queries>
    <application 
    android:icon="@drawable/app_icon" 
    android:label="@string/app_name" android:debuggable="false"
    android:configChanges="orientation|screenSize|locale"
    android:theme="@style/UnityThemeSelector">
    <activity 
      android:name="com.starseed.speechtotext.MainActivity" 
	    android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
      android:label="@string/app_name">
      <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
      </intent-filter>
    </activity>   
  </application>
</manifest>

Hey, I could actually found the solution in this thread: https://stackoverflow.com/questions/45992420/speechrecognizer-bind-to-recognition-service-failed

Just add this lines to your unityLibrary/manifests/AndroidManifest.xml: <queries> <package android:name="com.google.android.googlequicksearchbox"/> </queries>

Hey, I could actually found the solution in this thread: https://stackoverflow.com/questions/45992420/speechrecognizer-bind-to-recognition-service-failed

Just add this lines to your unityLibrary/manifests/AndroidManifest.xml: <queries> <package android:name="com.google.android.googlequicksearchbox"/> </queries>

Due to adding these lines There is an issue during build "package key is missing"

tibi321 avatar Sep 15 '21 04:09 tibi321

The update needed is in \SpeechToText_AppleAPI\Assets\Plugins\Android\AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
          package="com.starseed.speechtotext" 
		  android:versionCode="1" android:versionName="1.0">
  <uses-permission android:name="android.permission.RECORD_AUDIO" />
  <uses-permission android:name="android.permission.INTERNET" />
  <uses-sdk android:minSdkVersion="16" android:targetSdkVersion="23" />
    <queries>
        <package android:name="com.google.android.googlequicksearchbox"/>
    </queries>
    <application 
    android:icon="@drawable/app_icon" 
    android:label="@string/app_name" android:debuggable="false"
    android:configChanges="orientation|screenSize|locale"
    android:theme="@style/UnityThemeSelector">
    <activity 
      android:name="com.starseed.speechtotext.MainActivity" 
	    android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
      android:label="@string/app_name">
      <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
      </intent-filter>
    </activity>   
  </application>
</manifest>

Hey, I could actually found the solution in this thread: https://stackoverflow.com/questions/45992420/speechrecognizer-bind-to-recognition-service-failed Just add this lines to your unityLibrary/manifests/AndroidManifest.xml: <queries> <package android:name="com.google.android.googlequicksearchbox"/> </queries>

Hey, I could actually found the solution in this thread: https://stackoverflow.com/questions/45992420/speechrecognizer-bind-to-recognition-service-failed Just add this lines to your unityLibrary/manifests/AndroidManifest.xml: <queries> <package android:name="com.google.android.googlequicksearchbox"/> </queries>

Due to adding these lines There is an issue during build "package key is missing"

how will i solve this build error

tibi321 avatar Sep 15 '21 04:09 tibi321

@tibi321 https://www.youtube.com/watch?v=Tyv3PRbe9fs You have to increase the Gradle version as shown in that video

amromezzat avatar Oct 23 '21 22:10 amromezzat

@tibi321 https://www.youtube.com/watch?v=Tyv3PRbe9fs You have to increase the Gradle version as shown in that video

its worked!!...thanks bro

tibi321 avatar Oct 28 '21 12:10 tibi321

Hi there, I seem to be having the same issues as everyone else, but the solutions don't seem to be doing anything. Regarding upgrading the gradle version, the video says to upgrade it to 3.4.3, but on the latest version of unity it's already at 4.0.1, and going backwards doesn't seem to help. I have also copy and pasted the exact xml code to AndroidManifest.xml, so I've really seemed to hit a roadblock. Right now all I'm trying to do is to run the sample scene on my android phone and not get the Error Unity java.lang.ClassCastException: com.unity3d.player.UnityPlayerActivity cannot be cast to com.starseed.speechtotext.MainActivity error. Any help would go a long ways. Thanks so much. "

BrockyBoi avatar Nov 10 '21 20:11 BrockyBoi

Hi there, I seem to be having the same issues as everyone else, but the solutions don't seem to be doing anything. Regarding upgrading the gradle version, the video says to upgrade it to 3.4.3, but on the latest version of unity it's already at 4.0.1, and going backwards doesn't seem to help. I have also copy and pasted the exact xml code to AndroidManifest.xml, so I've really seemed to hit a roadblock. Right now all I'm trying to do is to run the sample scene on my android phone and not get the Error Unity java.lang.ClassCastException: com.unity3d.player.UnityPlayerActivity cannot be cast to com.starseed.speechtotext.MainActivity error. Any help would go a long ways. Thanks so much. "

https://github.com/j1mmyto9/Speech-And-Text-Unity-iOS-Android/issues/61

g5fighter avatar Dec 11 '21 16:12 g5fighter

I adjusted the manifests and it still does not work. Later I found out that I checked the Release option of Minify. After I unchecked the Minify option, it worked.

截圖 2021-12-24 上午10 21 00

jinhe1997 avatar Dec 24 '21 02:12 jinhe1997

After adding in menifest <queries> <package android:name="com.google.android.googlequicksearchbox"/> </queries>

I was experiencing crash with error 2022-05-05 18:51:21.677 32514 32514 Error AndroidRuntime FATAL EXCEPTION: main 2022-05-05 18:51:21.677 32514 32514 Error AndroidRuntime Process: com.starseed.speechandtext, PID: 32514 2022-05-05 18:51:21.677 32514 32514 Error AndroidRuntime java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Object java.util.ArrayList.get(int)' on a null object reference 2022-05-05 18:51:21.677 32514 32514 Error AndroidRuntime at com.starseed.speechtotext.MainActivity$3.onResults(MainActivity.java:115) 2022-05-05 18:51:21.677 32514 32514 Error AndroidRuntime at android.speech.SpeechRecognizer$InternalListener$1.handleMessage(SpeechRecognizer.java:459) 2022-05-05 18:51:21.677 32514 32514 Error AndroidRuntime at android.os.Handler.dispatchMessage(Handler.java:106) 2022-05-05 18:51:21.677 32514 32514 Error AndroidRuntime at android.os.Looper.loop(Looper.java:246) 2022-05-05 18:51:21.677 32514 32514 Error AndroidRuntime at android.app.ActivityThread.main(ActivityThread.java:8633) 2022-05-05 18:51:21.677 32514 32514 Error AndroidRuntime at java.lang.reflect.Method.invoke(Native Method) 2022-05-05 18:51:21.677 32514 32514 Error AndroidRuntime at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:602) 2022-05-05 18:51:21.677 32514 32514 Error AndroidRuntime at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1130)

Then I found a comment saying to add following in menifest <queries> <intent> <action android:name="android.speech.RecognitionService" /> </intent> </queries>

Now, app does not crash but when ever I am trying to detect speech it says following 2022-05-05 18:18:09.511 24114 24114 Error SpeechRecognizer bind to recognition service failed

DigvijaysinhGohil avatar May 05 '22 13:05 DigvijaysinhGohil

Hello All, In android 11 we got this issue, after searching a lot we found that by adding the below lines it should work : Error : Error SpeechRecognizer bind to recognition service failed

but our app was crashed & we got a new error please check the attached screenshot Can anyone help us to fix it? image_2022_05_05T13_21_56_935Z (1)

jayesh8585 avatar May 05 '22 13:05 jayesh8585

Hello All, In android 11 we got this issue, after searching a lot we found that by adding the below lines it should work : Error : Error SpeechRecognizer bind to recognition service failed

but our app was crashed & we got a new error please check the attached screenshot Can anyone help us to fix it? image_2022_05_05T13_21_56_935Z (1)

hi, did you manage to resolve this one your end? i'm facing this exact same error

MaekellMina avatar Jun 09 '22 08:06 MaekellMina

Hello All, In android 11 we got this issue, after searching a lot we found that by adding the below lines it should work : Error : Error SpeechRecognizer bind to recognition service failed but our app was crashed & we got a new error please check the attached screenshot Can anyone help us to fix it? image_2022_05_05T13_21_56_935Z (1)

hi, did you manage to resolve this one your end? i'm facing this exact same error

Hi, MaekellMina. No unfortunately we haven't managed to resolve the issue from our end, we are exploring other possible solutions at this stage. Will keep you posted if we find anything useful.

DigvijaysinhGohil avatar Jun 10 '22 07:06 DigvijaysinhGohil

Hi,

I have found a fix for this issue. Reason for crash was in MainActivity.java

@Override
public void onResults(Bundle results) {
      ArrayList<String> text = results.getStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION);
     /// For some reason `text`  is null.
     UnityPlayer.UnitySendMessage("SpeechToText", "onResults", text.get(0));// this line was crashing.
}

so I added a null check like this and built a new SpeechToTextPlugin.jar

@Override
public void onResults(Bundle results) {
    ArrayList<String> text = results.getStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION);
    if(text!=null && !text.isEmpty())
    {   
         UnityPlayer.UnitySendMessage("SpeechToText", "onResults", text.get(0));
    }else {
        UnityPlayer.UnitySendMessage("SpeechToText", "onResults", "null recieved");
    }
}

Solution:

  1. Download and extract following zip file. SpeechToTextPlugin.zip
  2. Replace new SpeechToTextPlugin.jar in 'Assets\Plugins\Android' folder.

Note:

For some reason we will get result in onPartialResultsCallback not in onResultCallback.

prakyath-07 avatar Jul 30 '23 17:07 prakyath-07