Firebase上传音频异常

时间:2016-10-26 10:47:07

标签: android firebase firebase-storage

我正在尝试使用Firebase从模拟器上传mp3音频文件并获得一些例外。该文件存在于“文件管理器”中 - > “下载”目录。权限是“INTERNET”和“READ_EXTERNAL_STORAGE。

@Override
public void onClick(View view) {
    Intent intent = new Intent();
    intent.setType("audio/*");
    intent.setAction(Intent.ACTION_GET_CONTENT);
    startActivityForResult(intent,REQ_CODE);
}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {


    StorageMetadata metadata = new StorageMetadata.Builder()
            .setContentType("audio/mp3")
            .build();
    FirebaseStorage fbStorageInstance = FirebaseStorage.getInstance();
    StorageReference  storageReference = fbStorageInstance.getReferenceFromUrl("gs://myfirebase-a8d58.appspot.com");
    Uri fileUri = data.getData();
    StorageReference audioRef = storageReference.child("Audio/" + fileUri.getLastPathSegment());
    UploadTask uploadTask = audioRef.putFile(fileUri,metadata);

    super.onActivityResult(requestCode, resultCode, data);

}

获得例外

10-26 06:28:04.215 2904-4269/com.example.vadik.myapplication E/NetworkRqFactoryProxy: NetworkRequestFactoryProxy failed with a RemoteException:
      com.google.android.gms.internal.zzsu$zza: No acceptable module found. Local version is 0 and remote version is 0.
       at com.google.android.gms.internal.zzsu.zza(Unknown Source)
       at com.google.android.gms.internal.zzanu.<init>(Unknown Source)
      at com.google.android.gms.internal.zzanu.zzj(Unknown Source)
      at com.google.firebase.storage.StorageReference.al(Unknown Source)
      at com.google.firebase.storage.UploadTask.ax(Unknown Source)
      at com.google.firebase.storage.UploadTask.run(Unknown Source)
      at com.google.firebase.storage.StorageTask$5.run(Unknown Source)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
      at java.lang.Thread.run(Thread.java:818)
10-26 06:28:04.215 2904-4269/com.example.vadik.myapplication E/UploadTask: Unable to create a network request from metadata
android.os.RemoteException
at com.google.android.gms.internal.zzanu.<init>(Unknown Source)
at com.google.android.gms.internal.zzanu.zzj(Unknown Source)
at com.google.firebase.storage.StorageReference.al(Unknown Source)
at com.google.firebase.storage.UploadTask.ax(Unknown Source)
at com.google.firebase.storage.UploadTask.run(Unknown Source)
at com.google.firebase.storage.StorageTask$5.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:818)
10-26 06:28:04.215 2904-4269/com.example.vadik.myapplication E/StorageException: StorageException has occurred.
 An unknown error occurred, please check the HTTP result code and inner exception for server response.
  Code: -13000 HttpResult: 0
10-26 06:28:04.215 2904-4269/com.example.vadik.myapplication E/StorageException: null
 android.os.RemoteException
     at com.google.android.gms.internal.zzanu.<init>(Unknown Source)
     at com.google.android.gms.internal.zzanu.zzj(Unknown Source)
     at com.google.firebase.storage.StorageReference.al(Unknown Source)
     at com.google.firebase.storage.UploadTask.ax(Unknown Source)
     at com.google.firebase.storage.UploadTask.run(Unknown Source)
     at com.google.firebase.storage.StorageTask$5.run(Unknown Source)
     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
     at java.lang.Thread.run(Thread.java:818)

1 个答案:

答案 0 :(得分:0)

FirebaseStorage需要google play服务。确保谷歌播放服务是他们的模拟器。