alan-ai / alan-sdk-flutter

Conversational AI SDK for Flutter to enable text and voice conversations with actions (iOS and Android)
https://alan.app
1.81k stars 39 forks source link

App crashing and alan not waking on hey alan call #11

Closed the-accidental-engineer closed 2 years ago

the-accidental-engineer commented 2 years ago

Error

E/AndroidRuntime(15726): FATAL EXCEPTION: main E/AndroidRuntime(15726): Process: com.example.ai_radio, PID: 15726 E/AndroidRuntime(15726): java.lang.ClassCastException: com.google.gson.internal.LinkedTreeMap cannot be cast to com.alan.alansdk.events.EventParsed$ParsedEntity E/AndroidRuntime(15726): at com.alan.alansdk.button.AlanStateListener.onParsedEvent(:1) E/AndroidRuntime(15726): at com.alan.alansdk.d.run(:6) E/AndroidRuntime(15726): at android.os.Handler.handleCallback(Handler.java:790) E/AndroidRuntime(15726): at android.os.Handler.dispatchMessage(Handler.java:99) E/AndroidRuntime(15726): at android.os.Looper.loop(Looper.java:192) E/AndroidRuntime(15726): at android.app.ActivityThread.main(ActivityThread.java:6711) E/AndroidRuntime(15726): at java.lang.reflect.Method.invoke(Native Method) E/AndroidRuntime(15726): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:549) E/AndroidRuntime(15726): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:826)

script AI_Radio_First_version_20211207_105241UTC.zip

repo link - https://github.com/Prateek0Srivastav/Radio-App if needed

code -

setUpAlan() { AlanVoice.addButton( "key/prod", buttonAlign: AlanVoice.BUTTON_ALIGN_RIGHT); AlanVoice.onCommand.add((command) { debugPrint("got new command ${command.toString()}"); _handleCommand(command.data); }); }

_handleCommand(Map<String, dynamic> response) { switch (response["command"]) { case "play": _playMusic(_selectedRadio!.url); break;

  case "play_channel":
    final id = response["id"];
    _audioPlayer.pause();
    MyRadio newRadio = radios!.firstWhere((element) => element.id == id);
    radios!.remove(newRadio);
    radios!.insert(0, newRadio);
    _playMusic(newRadio.url);
    break;

  case "stop":
    _audioPlayer.stop();
    break;

  case "next":
    final index = _selectedRadio!.id;
    MyRadio newRadio;
    if (index + 1 > radios!.length) {
      newRadio = radios!.firstWhere((element) => element.id == 1);
      radios!.remove(newRadio);
      radios!.insert(0, newRadio);
    } else {
      newRadio = radios!.firstWhere((element) => element.id == index + 1);
      radios!.remove(newRadio);
      radios!.insert(0, newRadio);
    }
    _playMusic(newRadio.url);
    break;

  case "prev":
    final index = _selectedRadio!.id;
    MyRadio newRadio;
    if (index - 1 <= 0) {
      newRadio =
          radios!.firstWhere((element) => element.id == radios!.length);
      radios!.remove(newRadio);
      radios!.insert(0, newRadio);
    } else {
      newRadio = radios!.firstWhere((element) => element.id == index - 1);
      radios!.remove(newRadio);
      radios!.insert(0, newRadio);
    }
    _playMusic(newRadio.url);
    break;

  default:
    print("Command was ${response["command"]}");
}

}

snyuryev commented 2 years ago

@Prateek0Srivastav I will take a look.

Could you provide steps with your script. What command is not working?

the-accidental-engineer commented 2 years ago

As of now only play and pause command work and all other command may cause app crash with above mentioned error get a clone of my repo and run flutter run --release and try play music. hey alan also not waking up the assistant

snyuryev commented 2 years ago

@Prateek0Srivastav Is it the same issue with debug build?

the-accidental-engineer commented 2 years ago

@snyuryev no this happen in the release only.

snyuryev commented 2 years ago

@Prateek0Srivastav

Please try to add additional params for release build type

shrinkResources false
minifyEnabled false

to your build.gradle file. It should be located

[your_app_folder]/android/app/build.gradle

As result you should have something similar to:

buildTypes {
        release {
            signingConfig signingConfigs.debug
            shrinkResources false
            minifyEnabled false
        }
}

After that please try to run

snyuryev commented 2 years ago

@Prateek0Srivastav

Also updated version on plugin (3.3.0) is available. Please try this one.

snyuryev commented 2 years ago

Fixed with previous release. Please create a new issue if you need any additional help.