dialogflow::unavailable:凭据无法获取元数据

i7uq4tfw  于 2021-06-27  发布在  Java
关注(0)|答案(0)|浏览(196)

我正在为我的voicebot android应用程序使用dialogflow。
该应用程序在调试模式下运行正常,但在安装release apk dialogflow时出现错误:
不可用:凭据无法获取元数据
要生成sessionclient:

  1. try {
  2. InputStream stream = context.getResources().openRawResource(R.raw.poc_9c75a7f4);
  3. GoogleCredentials credentials = GoogleCredentials.fromStream(stream);
  4. projectId = ((ServiceAccountCredentials) credentials).getProjectId();
  5. SessionsSettings.Builder settingsBuilder = SessionsSettings.newBuilder();
  6. SessionsSettings sessionsSettings = settingsBuilder.setCredentialsProvider(FixedCredentialsProvider.create(credentials)).build();
  7. sessionsClient = SessionsClient.create(sessionsSettings);
  8. } catch (Exception e) {
  9. Print.printStackTrace(e);
  10. }

向dialogflow发送请求:

  1. try {
  2. DetectIntentRequest intentRequest = DetectIntentRequest.newBuilder()
  3. .setSession(session.toString())
  4. .setQueryInput(queryInput)
  5. .build();
  6. DetectIntentResponse detectIntentResponse = sessionsClient.detectIntent(intentRequest);
  7. String botResponse = detectIntentResponse.getQueryResult().getFulfillmentText();
  8. dialogflowCallback.updateUI(botResponse);
  9. } catch (Exception e) {
  10. Print.printStackTrace(e);
  11. }

请帮我解决这个问题。

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题