title: how to resolve java.lang.IllegalStateException: Task is not yet complete Error when uploading image to Firebase storage?
body: <p>I started to have this error after I updated firebase storage to the latest version 16.0.1. I didn't change anything in my code i just got this error after upgrading gradle build dependencies</p>
  <h1>AskFirebase</h1>
  <pre><code>uploadTask.addOnCompleteListener(new OnCompleteListener&lt;UploadTask.TaskSnapshot&gt;() {
          @Override
          public void onComplete(@NonNull Task&lt;UploadTask.TaskSnapshot&gt; task) {
  
  
              if (task.isSuccessful()) {
                  Uri downloadUri = task.getResult().getStorage().getDownloadUrl().getResult();
  
                  if (downloadUri == null)
                      return ;
  
  
                  downloadUriArray.add(String.valueOf(downloadUri));
  
                  singleAdImageArrayList.get(uriIndex).setUploading(false);
                  singleAdImageArrayList.get(uriIndex).setImgDownloadUri(downloadUri);
                  singleAdImageArrayList.get(uriIndex).setSent(true);
                  singleAdImageArrayList.get(uriIndex).setHasLocalUri(false);
                  sendImagesUpdateToActivity();
  
                  checkCompletion();
  
                  Toast.makeText(getApplicationContext(), &quot;sent successfully&quot;, Toast.LENGTH_LONG).show();
                  return ;
  
              }else {
  
                  singleAdImageArrayList.get(uriIndex).setUploading(false);
                  singleAdImageArrayList.get(uriIndex).setFailUploading(true);
                  sendImagesUpdateToActivity();
  
                  failuresCounter++;
                  if (task.getException() != null &amp;&amp; task.getException().getMessage() != null) {
                      Log.d(TAG, &quot;onComplete: failed exception: &quot; + task.getException().getMessage());
                      QuickToastUtil.makeToast(getApplicationContext(), getString(R.string.network_error), false);
                  }
  
                  checkCompletion();
  
                  return ;
              }
  
          }
      });
  </code></pre>