title: GOOGLE_APPLICATION_CREDENTIALS can't be found
body: <p>Currently have to integrate Google Cloud Platform services into my app but recieving the following exception:</p>
  <pre><code>**W/System.err: java.io.IOException: The Application Default Credentials are not available. They are available if running in Google Compute Engine. Otherwise, the environment variable GOOGLE_APPLICATION_CREDENTIALS must be defined pointing to a file defining the credentials. See https://developers.google.com/accounts/docs/application-default-credentials for more information.
          at com.google.auth.oauth2.DefaultCredentialsProvider.getDefaultCredentials(DefaultCredentialsProvider.java:134)
  W/System.err:     at com.google.auth.oauth2.GoogleCredentials.getApplicationDefault(GoogleCredentials.java:119)
          at com.google.auth.oauth2.GoogleCredentials.getApplicationDefault(GoogleCredentials.java:91)
          at com.google.api.gax.core.GoogleCredentialsProvider.getCredentials(GoogleCredentialsProvider.java:67)
          at com.google.api.gax.rpc.ClientContext.create(ClientContext.java:135)
          at com.google.cloud.speech.v1.stub.GrpcSpeechStub.create(GrpcSpeechStub.java:94)
          at com.google.cloud.speech.v1.stub.SpeechStubSettings.createStub(SpeechStubSettings.java:131)
          at com.google.cloud.speech.v1.SpeechClient.&lt;init&gt;(SpeechClient.java:144)
          at com.google.cloud.speech.v1.SpeechClient.create(SpeechClient.java:126)
          at com.google.cloud.speech.v1.SpeechClient.create(SpeechClient.java:118)
          at com.dno.app.ui.TranscriptFragment$1.onClick(TranscriptFragment.java:72)**
  </code></pre>
  <p>Environment variable is set:</p>
  <p><a href="https://i.stack.imgur.com/uvMcN.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/uvMcN.png" alt="environment_variable" /></a></p>
  <p>.json file is here:</p>
  <p><a href="https://i.stack.imgur.com/KbKyE.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/KbKyE.png" alt=".json file" /></a></p>
  <p>the app crashes at authImplicit() in this code block (fragment):</p>
  <pre><code>    transcriptBtn = getActivity().findViewById(R.id.transcript_button);
      transcriptBtn.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
              try (SpeechClient speechClient = SpeechClient.create()) {
                  authImplicit(); // issue with Google Platform Login Authentification
                  // - does not read the environment variable, and therefore cannot get access to the .json file.
  
                  // The path to the audio file to transcribe
                  String fileName = getFile().getName();
  
                  // Reads the audio file into memory
                  Path path = Paths.get(fileName);
  
                  byte[] data = Files.readAllBytes(path);
                  ByteString audioBytes = ByteString.copyFrom(data);
  
                  // Builds the sync recognize request
                  RecognitionConfig config =
                          RecognitionConfig.newBuilder()
                                  .setEncoding(RecognitionConfig.AudioEncoding.FLAC)
                                  .setSampleRateHertz(16000)
                                  .setLanguageCode(&quot;en-US&quot;)
                                  .build();
                  RecognitionAudio audio = RecognitionAudio.newBuilder().setContent(audioBytes).build();
  
                  // Performs speech recognition on the audio file
                  RecognizeResponse response = speechClient.recognize(config, audio);
                  List&lt;SpeechRecognitionResult&gt; results = response.getResultsList();
  
                  for (SpeechRecognitionResult result : results) {
                      // There can be several alternative transcripts for a given chunk of speech. Just use the
                      // first (most likely) one here.
                      SpeechRecognitionAlternative alternative = result.getAlternativesList().get(0);
                      System.out.printf(&quot;Transcription: %s%n&quot;, alternative.getTranscript());
                  }
              } catch (IOException e) {
                  e.printStackTrace();
              }
          }
      });
  </code></pre>
  <p>code for authImplicit():</p>
  <pre><code> private void authImplicit() {
          // If you don't specify credentials when constructing the client, the client library will
          // look for credentials via the environment variable GOOGLE_APPLICATION_CREDENTIALS.
          Storage storage = StorageOptions.getDefaultInstance().getService();
  
          System.out.println(&quot;Buckets:&quot;);
          Page&lt;Bucket&gt; buckets = storage.list();
          for (Bucket bucket : buckets.iterateAll()) {
              System.out.println(bucket.toString());
          }
      }
  </code></pre>
  <p>I have selected a service account of the type, Owner, so I shouldn't be lacking any permissions.</p>
  <p><strong>EDIT</strong> (Still not working):
  I tried using this example but it still doesn't work: <a href="https://stackoverflow.com/questions/55496769/the-application-default-credentials-are-not-available?rq=1">The Application Default Credentials are not available</a></p>
  <p><strong>EDIT #2</strong> (Working on server-side):
  As it turns out, Google does not currently support Android for this task. Since this, I've moved the code to an ASP.NET back-end, and the code is now running smoothly.</p>
  <p>Thank you for the assistance below.</p>