0

I am trying to access a .json file in src/main/resources in an android project but I keep getting that the variable input is null

I've made sure that the file is in the specified location.

private val CREDENTIALS_FILE_PATH = "src/main/resources/credentials.json"
private var input = javaClass.getResourceAsStream(CREDENTIALS_FILE_PATH)

I'm not sure why this is happening. Is my syntax wrong? Thanks!

  • Does this answer your question? [Android read text raw resource file](https://stackoverflow.com/questions/4087674/android-read-text-raw-resource-file) – Edric Nov 16 '22 at 01:40
  • Android apps don’t compile like JVM apps. You have to put your resource in a specific location or it won’t be available in the compiled app. Read the documentation on raw resources. – Tenfour04 Nov 16 '22 at 04:38
  • I figured it out. Thanks for the advice!! –  Nov 16 '22 at 19:55

0 Answers0