资源未找到:/credentials.json Google Sheets API

huangapple go评论111阅读模式
英文:

Resource not found: /credentials.json Google Sheets API

问题

我按照Google Sheets快速入门指南并下载了credentials.json,将其放在我的项目main/res目录中。无论我如何更改位置,它始终显示错误java.io.FileNotFoundException: 未找到资源:/credentials.json

我尝试了这篇帖子中找到的另一种方法:
https://stackoverflow.com/questions/59292883/java-io-filenotfoundexception-resource-not-found-credentials-json-on-java-qui

但仍然相同。
有人可以告诉我如何修复吗?我已经谷歌了很长时间。谢谢

资源未找到:/credentials.json Google Sheets API

英文:

I follow the google Sheets quickstart and download the credentials.json put in my project main/res.
No matter how I change the place, it always shows the error java.io.FileNotFoundException: Resource not found: /credentials.json

I have tried the other way that I found in this post:
https://stackoverflow.com/questions/59292883/java-io-filenotfoundexception-resource-not-found-credentials-json-on-java-qui

But still the same.
Can anyone tell me how to fix it? I google it for a long time. Thanks
资源未找到:/credentials.json Google Sheets API

答案1

得分: 1

你将 credentials.json 文件存储在主应用程序文件夹中,但是正如你在 Sheets API 的对应 Java 快速入门 中所看到的,该文件应该位于 src/main/resources/ 文件夹中。

将文件移动到指定位置可能会解决你的问题。

英文:

You are storing the credentials.json file in the main app folder but, as you can see in the corresponding Java Quickstart for Sheets API, this file should be in src/main/resources/.

Your issue should be solved by moving the file to the specified location.

答案2

得分: 1

我使用Android Studio,并通过创建res/raw文件夹来解决了这个问题。

然后将credential.json移动到其中。

然后使用以下代码来访问它。

InputStream in = this.getResources().openRawResource(R.raw.credentials);
英文:

I use the android studio, and I solved it by created a res/raw folder.

Then moved the credential.json into it.

And use the following code instead to access it.

InputStream in = this.getResources().openRawResource(R.raw.credentials);

huangapple
  • 本文由 发表于 2020年9月18日 00:06:58
  • 转载请务必保留本文链接:https://go.coder-hub.com/63942012.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定