Penny Chen
Penny Chen

Reputation: 79

Resource not found: /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: 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

Upvotes: 1

Views: 2082

Answers (2)

Null Bite
Null Bite

Reputation: 127

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

Upvotes: 1

Iamblichus
Iamblichus

Reputation: 19309

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.

Upvotes: 1

Related Questions