khanhuitse05 / speech-and-text-unity-ios-android

Speed to text in Unity iOS use Native Speech Recognition
MIT License
286 stars 124 forks source link

Not working on Android 11 #58

Open deadlyghost753 opened 2 years ago

deadlyghost753 commented 2 years ago

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?

denyslave commented 2 years ago

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

joepeaden commented 2 years ago

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

denyslave commented 2 years ago

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>

riesvriend commented 2 years ago

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>
tibi321 commented 2 years ago

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 commented 2 years ago

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

amromezzat commented 2 years ago

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

tibi321 commented 2 years ago

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

its worked!!...thanks bro

BrockyBoi commented 2 years ago

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. "

g5fighter commented 2 years ago

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

jinhe1997 commented 2 years ago

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

DigvijaysinhGohil commented 2 years ago

After adding in menifest `

</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 `

`

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

jayesh8585 commented 2 years ago

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)

MaekellMina commented 2 years ago

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

DigvijaysinhGohil commented 2 years ago

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.

prakyath-07 commented 11 months ago

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.