title: Firebase Test lab CI upload apks
body: <p>When setting up my buildserver to use Firebase Test Lab for espresso testing I keep running into the error.</p>
  
  <pre><code>ERROR: (gcloud.beta.test.android.run) Permission denied while fetching the default results bucket 
  (Error 403: Access Not Configured. Cloud Tool Results API has not been used in project CLOUD_PROJECT_ID before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/toolresults/overview?project=CLOUD_PROJECT_ID then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.).
  Is billing enabled for project: [PROJECT_ID]?
  </code></pre>
  
  <p>When I try it on my own machine which is logged in via my own account, running the command below works correctly.</p>
  
  <pre><code>gcloud beta test android run \
    --type instrumentation \
    --app app-debug.apk \
    --test app-debug-androidTest.apk \
    --device-ids Nexus4,Nexus5 \
    --os-version-ids 18,21,25 \
    --locales en \
    --orientations portrait
  </code></pre>
  
  <p>On my build server I want to use a service-account but when I execute the command I get the error mentioned earlier. Does anyone know what the correct way is to set this up? Does the service-account need some special role beside <code>project editor</code>?</p>
  
  <p>In the build script I execute the commands below to authenticate and set the project before uploading the APK's</p>
  
  <pre><code>gcloud config set project PROJECT_ID
  gcloud auth activate-service-account service-account@email.address --key-file ~/gcloud-service-key.json
  </code></pre>