dialogflow / dialogflow-android-client

Android SDK for Dialogflow
https://dialogflow.com
Apache License 2.0
574 stars 270 forks source link

Application crashing after receiving speech input #19

Closed manas-mukherjee closed 8 years ago

manas-mukherjee commented 8 years ago

I followed the instruction and tried to run it in my Nexus-6P. After receiving the speech input, the application crashes without showing any error msg. Please help.

here is my MainActivity code.

package poc.apiai.com.firstaiapiapp;

import android.support.v7.app.AppCompatActivity; import android.os.Bundle;

import ai.api.AIConfiguration; import ai.api.AIListener; import ai.api.AIService; import ai.api.model.AIError; import ai.api.model.AIResponse; import ai.api.model.Result; import com.google.gson.JsonElement; import java.util.Map;

import android.view.View; import android.widget.Button; import android.widget.TextView;

public class MainActivity extends AppCompatActivity implements AIListener {

private Button listenButton;
private TextView resultTextView;
private AIService aiService;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    listenButton = (Button) findViewById(R.id.listenButton);
    resultTextView = (TextView) findViewById(R.id.resultTextView);

    final AIConfiguration config = new AIConfiguration("abc",
            AIConfiguration.SupportedLanguages.English,
            AIConfiguration.RecognitionEngine.System);

    aiService = AIService.getService(this, config);
    aiService.setListener(this);
}

public void listenButtonOnClick(final View view) {
    aiService.startListening();
}

@Override
public void onResult(AIResponse response) {
    Result result = response.getResult();

    // Get parameters
    String parameterString = "";
    if (result.getParameters() != null && !result.getParameters().isEmpty()) {
        for (final Map.Entry<String, JsonElement> entry : result.getParameters().entrySet()) {
            parameterString += "(" + entry.getKey() + ", " + entry.getValue() + ") ";
        }
    }

    // Show results in TextView.
    resultTextView.setText("Query:" + result.getResolvedQuery() +
            "\nAction: " + result.getAction() +
            "\nParameters: " + parameterString);
}

@Override
public void onError(AIError error) {
    resultTextView.setText(error.toString());
}

@Override
public void onAudioLevel(float level) {

}

@Override
public void onListeningStarted() {

}

@Override
public void onListeningCanceled() {

}

@Override
public void onListeningFinished() {

}

}

Looking fwd to your reply.

Thanks

manas-mukherjee commented 8 years ago

Please ignore this comment. I change a stable version of common-io lib instead of compile 'commons-io:commons-io:20030203.000550'. It fixed the issue. Android SDK is great. Thanks

Aashit-Sharma commented 7 years ago

@manas-mukherjee ,which stable version of common-io lib was it that worked for you ? I am still getting a crash on listening (only when I say a long sentence)