title: SafetyNet attestation fails with internal error
body: <p>I want to use the <a href="https://developer.android.com/training/safetynet/attestation.html" rel="nofollow noreferrer">SafetyNet Attestation API</a> (<em>mind that this documentation seems to be outdated since the methods it uses are deprecated</em>). Using the latest version of Play Services (11.0.1) I came up with the following code:</p>
  
  <pre><code>SecureRandom secureRandom = new SecureRandom();
  byte[] nonce = new byte[16];
  secureRandom.nextBytes(nonce); // just some random bytes for testing
  
  SafetyNet.getClient(this)
      .attest(nonce, API_KEY)
      .addOnCompleteListener(this, task -&gt; {
          if (task.isSuccessful()) {
              SafetyNetApi.AttestationResponse result = task.getResult();
              String jws = result.getJwsResult();
              Log.d(TAG, "JWS: " + jws);
          } else {
              Exception e = task.getException();
  
              if (e instanceof ApiException) {
                  Log.e(TAG, "Attestation failure: " + ((ApiException) e).getStatusMessage() + ", code: " + ((ApiException) e).getStatusCode(), e);
              } else {
                  Log.e(TAG, "Attestation failure: " + e, e);
              }
          }
      });
  </code></pre>
  
  <p>where <code>API_KEY</code> is the API key from the Google Developer Console. This code is called in an <code>Activity</code>'s <code>onCreate(...)</code>. Whatever I tried, it results in failure and the <code>e</code> is an instance of <code>ApiException</code>, but it does not provide any useful information about what went wrong since the status message is <code>null</code> and the status code is 8, which - according to <a href="https://developers.google.com/android/reference/com/google/android/gms/common/api/CommonStatusCodes#INTERNAL_ERROR" rel="nofollow noreferrer">the documentation</a> - is an "internal error". I tried to call this with a 5 second delay but no success. The test device has API 24 and Google Play services 11.0.55.</p>
  
  <p>Anyone has any idea what goes wrong and what's the solution for this?</p>
  
  <hr>
  
  <p><strong>Edit</strong>: the old <code>SafetyNet.SafetyNetApi.attest(googleApiClient, nonce)</code> way seems to work fine but it's deprecated so I don't want to use it.</p>