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

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

java.lang.ClassCastException #61

Open JebarajDaniel opened 3 years ago

JebarajDaniel commented 3 years ago

When i am trying to use Speech To Text in My app. Am getting this error. java.lang.ClassCastException: com.unity3d.player.UnityPlayerActivity cannot be cast to com.starseed.speechtotext.MainActivity java.lang.ClassCastException: com.unity3d.player.UnityPlayerActivity cannot be cast to com.starseed.speechtotext.MainActivity at com.starseed.speechtotext.Bridge.StartRecording(Bridge.java:32) at com.unity3d.player.UnityPlayer.nativeRender(Native Method) at com.unity3d.player.UnityPlayer.access$300(Unknown Source:0) at com.unity3d.player.UnityPlayer$e$1.handleMessage(Unknown Source:95)

Can you help me to resolve this issue?

aneeb111 commented 2 years ago

You have to edit your AndroidManifest.xml file. You need to specify the plugin's MainActivity inside application tag instead of android:name="com.unity3d.player.UnityPlayerActivity" , Change the lines to

`

  <meta-data android:name="unityplayer.UnityActivity" android:value="true" />
</activity>`
Ilya171 commented 2 years ago

same error, did you fix it? my manifest

**<?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" />
  <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>
      <meta-data android:name="unityplayer.UnityActivity" android:value="true" />
    </activity>   
  </application>
</manifest>**``
Jack-Smith-Hocking commented 11 months ago

Had the same issue, the fix suggested by aneeb111 seems to have fixed it. My manifest looks like this:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

  <uses-permission android:name="android.permission.RECORD_AUDIO" />
  <uses-permission android:name="android.permission.INTERNET" />
  <application>
    <activity 
      android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
      android:name="com.starseed.speechtotext.MainActivity"
      android:label="@string/app_name">
      <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
      </intent-filter>
      <meta-data android:name="unityplayer.UnityActivity" android:value="true" />
    </activity>   
  </application>
</manifest>