我正在为我的voicebot android应用程序使用dialogflow。
该应用程序在调试模式下运行正常,但在安装release apk dialogflow时出现错误:
不可用:凭据无法获取元数据
要生成sessionclient:
try {
InputStream stream = context.getResources().openRawResource(R.raw.poc_9c75a7f4);
GoogleCredentials credentials = GoogleCredentials.fromStream(stream);
projectId = ((ServiceAccountCredentials) credentials).getProjectId();
SessionsSettings.Builder settingsBuilder = SessionsSettings.newBuilder();
SessionsSettings sessionsSettings = settingsBuilder.setCredentialsProvider(FixedCredentialsProvider.create(credentials)).build();
sessionsClient = SessionsClient.create(sessionsSettings);
} catch (Exception e) {
Print.printStackTrace(e);
}
向dialogflow发送请求:
try {
DetectIntentRequest intentRequest = DetectIntentRequest.newBuilder()
.setSession(session.toString())
.setQueryInput(queryInput)
.build();
DetectIntentResponse detectIntentResponse = sessionsClient.detectIntent(intentRequest);
String botResponse = detectIntentResponse.getQueryResult().getFulfillmentText();
dialogflowCallback.updateUI(botResponse);
} catch (Exception e) {
Print.printStackTrace(e);
}
请帮我解决这个问题。
暂无答案!
目前还没有任何答案,快来回答吧!