1

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: java.io.FileNotFoundException: Resource not found: /credentials.json on Java QuickStart for Classroom API

But still the same. Can anyone tell me how to fix it? I google it for a long time. Thanks enter image description here

Penny Chen
  • 79
  • 1
  • 10
  • What quickstart are you following? [This one](https://developers.google.com/calendar/quickstart/java)? If that's the case, the file should be in `src/main/resources/`, as explained there. – Iamblichus Sep 18 '20 at 10:48
  • Hi, I follow the Google Sheets v4, but I'm developing an app in the android studio.I thought just put in my app folder. is it wrong? – Penny Chen Sep 18 '20 at 11:56
  • Sorry I meant to reference the sheet one: [Java quickstart](https://developers.google.com/sheets/api/quickstart/java). But that doesn't change the point, the OAuth process is the same for both APIs. The credentials should be in `src/main/resources/`. That's where the app is looking for it. – Iamblichus Sep 18 '20 at 12:15

2 Answers2

1

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.

Iamblichus
  • 18,540
  • 2
  • 11
  • 27
  • I move to src/main/res, still the same. or I should create an asset folder call "resourcrs"?? I update the picture on the post. – Penny Chen Sep 18 '20 at 12:32
  • Are you following the referenced quickstart? Did you build the project via `gradle run`? Can you provide the code related to the authorization process? – Iamblichus Sep 18 '20 at 12:47
  • Sorry, no. I do it and then show the error in terminal: Task 'run' not found in root project 'PhoneCallReminder'. – Penny Chen Sep 18 '20 at 13:05
  • @PennyChen I thought you were following the `google Sheets quickstart`? https://developers.google.com/sheets/api/quickstart/java – Iamblichus Sep 18 '20 at 13:28
  • How can I do it in Python? Having the same issue, downloaded the credencials to my main project folder – Murilo Melo May 16 '22 at 14:58
1

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);

Null Bite
  • 97
  • 8