Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fatal exception: main #10

Closed
erueloi opened this issue Jan 10, 2022 · 13 comments
Closed

Fatal exception: main #10

erueloi opened this issue Jan 10, 2022 · 13 comments
Assignees

Comments

@erueloi
Copy link

erueloi commented Jan 10, 2022

Hello,

Code in Alan Studio on load and execute is:

//Is a Json with pokemon data same this:
project.pokemons = [
{
form: "Normal",
pokemon_id: 663,
pokemon_name: "Talonflame",
type: [
"Fire",
"Flying"
]
},
{
form: "Normal",
pokemon_id: 664,
pokemon_name: "Scatterbug",
type: [
"Bug"
]
},
...

onCreateProject(() => {
project.pokemonsdata = project.pokemons.map(p => ${p.pokemon_name}~${p.pokemon_id}).join('|');
console.log(project.pokemonsdata);
});

const userInput = context(() => {
console.log(project.pokemonsdata);
follow("$(POKEMON~ p:pokemonsdata)", p => p.resolve(p.POKEMON.value));
})

intent("Add (first|lead) (Poke|Pokemon) (1|one)", async p => {
p.play("What pokemon add?");
var pokemon = await p.then(userInput);
console.log(pokemon);
p.play({command: "pokemon1", value: pokemon});
});

When play a command with values return error:
"E/AndroidRuntime(29591): java.lang.ClassCastException: com.google.gson.internal.LinkedTreeMap cannot be cast to com.alan.alansdk.events.EventParsed$ParsedEntity
E/AndroidRuntime(29591): at com.alan.alansdk.button.AlanStateListener.onParsedEvent(:1)
E/AndroidRuntime(29591): at com.alan.alansdk.d.run(:6)
E/AndroidRuntime(29591): at android.os.Handler.handleCallback(Handler.java:938)
E/AndroidRuntime(29591): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(29591): at android.os.Looper.loop(Looper.java:236)
E/AndroidRuntime(29591): at android.app.ActivityThread.main(ActivityThread.java:8056)
E/AndroidRuntime(29591): at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(29591): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:656)
E/AndroidRuntime(29591): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:967)"

Can you help me with the error? I don't know if the syntax is incorrect or an internal error.

Thks.

@snyuryev snyuryev self-assigned this Jan 11, 2022
@snyuryev
Copy link
Contributor

Hey @erueloi

I did a small adjustment for your script (please take a look to pokemonsPattern) and tried to run it with flutter app.
Works fine.

project.pokemons = [
    {
        form: "Normal",
        pokemon_id: 663,
        pokemon_name: "Talonflame",
        type: [
            "Fire",
            "Flying"
        ]
    },
    {
        form: "Normal",
        pokemon_id: 664,
        pokemon_name: "Scatterbug",
        type: [
            "Bug"
        ]
    }
];

const pokemonsPattern = project.pokemons.map(p => `${p.pokemon_name}~${p.pokemon_id}`).join('|');

const userInput = context(() => {
    follow(`$(POKEMON~ ${pokemonsPattern})`, p => p.resolve(p.POKEMON.value));
})

intent("Add (first|lead) (Poke|Pokemon) (1|one)", async p => {
    p.play("What pokemon add?");
    var pokemon = await p.then(userInput);
    p.play(`Adding ${pokemon}`);
    p.play({command: "pokemon1", value: pokemon});
});

Please try and let me know if it works for you.

Thanks.

@erueloi
Copy link
Author

erueloi commented Jan 20, 2022

Hello,

Thks for your answer, but error persists with same error in "java.lang.ClassCastException":

E/AndroidRuntime(24889): java.lang.ClassCastException: com.google.gson.internal.LinkedTreeMap cannot be cast to com.alan.alansdk.events.EventParsed$ParsedEntity
E/AndroidRuntime(24889): 	at com.alan.alansdk.button.AlanStateListener.onParsedEvent(:1)

For more information, i call AlanVoice in a button on a Flutter App inside a "Widget build(BuildContext context)":

void initAlan() {
      AlanVoice.addButton("key",
          buttonAlign: AlanVoice.BUTTON_ALIGN_LEFT);
      AlanVoice.setLogLevel("all");    
      AlanVoice.onCommand.add((command) => _handleCommand(command));

   }

And handle command function get de command data "value":

Future<void> _handleCommand(Map<String, dynamic> command) async {

switch (command["command"]) {
...
}}

Thks.

@snyuryev
Copy link
Contributor

@erueloi what version of alan_voice are you using?
I've been testing 3.1.0 with no error.

Could you provide whole script if it is possible?

@erueloi
Copy link
Author

erueloi commented Jan 20, 2022

@snyuryev yes, use alan_voice 3.1.0.

In debug mode it works correctly, but when use in release mode it fails.

@snyuryev
Copy link
Contributor

@erueloi got it. will try in release mode.

@snyuryev
Copy link
Contributor

@erueloi Release build (with script above) is working fine for me.

I/flutter (16571): got new command {command: pokemon1, value: Scatterbug}

What is "value" in your scenario?
Could you provide a script from Alan Studio which you are using. Or provide minimal reproducible example.

@erueloi
Copy link
Author

erueloi commented Jan 20, 2022

@snyuryev the command value is a return of "userInput"

This is the script:

project.pokemons = [
    {
        form: "Normal",
        pokemon_id: 663,
        pokemon_name: "Talonflame",
        type: [
            "Fire",
            "Flying"
        ]
    },
    {
        form: "Normal",
        pokemon_id: 664,
        pokemon_name: "Scatterbug",
        type: [
            "Bug"
        ]
    }
];

const pokemonsPattern = project.pokemons.map(p => `${p.pokemon_name}~${p.pokemon_id}`).join('|');

const userInput = context(() => {
    //console.log(project.pokemonsdata);
    follow(`$(POKEMON~ ${pokemonsPattern})`, p => p.resolve(p.POKEMON.value));
})

intent("Add (first|lead) (Poke|Pokemon) (1|one)", async p => {
    p.play("What pokemon one add?");    
    var pokemon = await p.then(userInput);
    p.play(`Adding ${pokemon}`);
    p.play({command: "pokemon1", value: pokemon});
    p.state.pokemon1 = pokemon;    
    p.play(`Pokemon one added is: ${pokemon}`);
});

Commandsthat do not return anything work correctly, for example:

intent("(Add|New) battle", async p => {    
    p.play({command: "newbattle"});
    p.play('New battle created, add pokemons!');
});

Release print <<<<

I/flutter (22854): got new command {command: newbattle}
E/AndroidRuntime(22854): FATAL EXCEPTION: main
E/AndroidRuntime(22854): Process: com.erueloi.pogobattlestatics, PID: 22854
E/AndroidRuntime(22854): java.lang.ClassCastException: com.google.gson.internal.LinkedTreeMap cannot be cast to com.alan.alansdk.events.EventParsed$ParsedEntity

thks for your help!

@snyuryev
Copy link
Contributor

@erueloi we tried to reproduce this issue and no luck.
Could you share your project on flutter (at least part with _handleCommand)

@the-accidental-engineer
Copy link

@snyuryev facing same issue please look into my issue if you time.
@erueloi did you find the solution ? if yes please let me know.

@erueloi
Copy link
Author

erueloi commented Mar 7, 2022

@Prateek0Srivastav no, the issue continues to fail.

@snyuryev
Copy link
Contributor

snyuryev commented Mar 10, 2022

@erueloi

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
Copy link
Contributor

@erueloi

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

@snyuryev
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants