无法通过android studio从firebase下载文件

时间:2017-08-19 08:59:19

标签: firebase storage android-studio-2.2

我只想从Firebase存储中下载图片,但我遇到了这些问题。我的谷歌播放服务是最新的。我有一个图像" dog.jpg"在桶中,没有其他文件。 Firebase bucket

我的主要活动代码



public class MainActivity extends AppCompatActivity {
    private StorageReference pathRef = FirebaseStorage.getInstance().getReference().child("dog.jpg");
    private ImageView imageView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        this.imageView = (ImageView) this.findViewById(R.id.imageView);
    }

    public void getImage(View v){
        File localFile;
        try {
            localFile = File.createTempFile("images","jpg");
            pathRef.getFile(localFile).addOnSuccessListener(new OnSuccessListener<FileDownloadTask.TaskSnapshot>() {
                @Override
                public void onSuccess(FileDownloadTask.TaskSnapshot taskSnapshot) {
                    //Local temp file has been created
                    Toast.makeText(MainActivity.this, "Success", Toast.LENGTH_SHORT).show();
                }
            }).addOnFailureListener(new OnFailureListener() {
                @Override
                public void onFailure(@NonNull Exception e) {
                    //handle error
                    Toast.makeText(MainActivity.this, e.getMessage()+"\n"+e.getCause(), Toast.LENGTH_LONG).show();
                }
            });
        }catch (IOException exception){
            Toast.makeText(this, "IOEXCEPTION", Toast.LENGTH_SHORT).show();
        }
    }
}
&#13;
&#13;
&#13;

我得到的错误。

&#13;
&#13;
W/GooglePlayServicesUtil: Google Play services out of date.  Requires 11020000 but found 9683470
W/DynamiteModule: Local module descriptor class for com.google.android.gms.firebasestorage not found.
I/DynamiteModule: Considering local module com.google.android.gms.firebasestorage:0 and remote module com.google.android.gms.firebasestorage:0
E/NetworkRqFactoryProxy: NetworkRequestFactoryProxy failed with a RemoteException:
                         com.google.android.gms.dynamite.DynamiteModule$zzc: No acceptable module found. Local version is 0 and remote version is 0.
                             at com.google.android.gms.dynamite.DynamiteModule.zza(Unknown Source)
                             at com.google.android.gms.internal.ace.<init>(Unknown Source)
                             at com.google.android.gms.internal.ace.zzg(Unknown Source)
                             at com.google.firebase.storage.FileDownloadTask.run(Unknown Source)
                             at com.google.firebase.storage.zzr.run(Unknown Source)
                             at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
                             at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
                             at java.lang.Thread.run(Thread.java:761)
E/FileDownloadTask: Unable to create firebase storage network request.
                    android.os.RemoteException
                        at com.google.android.gms.internal.ace.<init>(Unknown Source)
                        at com.google.android.gms.internal.ace.zzg(Unknown Source)
                        at com.google.firebase.storage.FileDownloadTask.run(Unknown Source)
                        at com.google.firebase.storage.zzr.run(Unknown Source)
                        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
                        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
                        at java.lang.Thread.run(Thread.java:761)
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
E/StorageException: null
                    android.os.RemoteException
                        at com.google.android.gms.internal.ace.<init>(Unknown Source)
                        at com.google.android.gms.internal.ace.zzg(Unknown Source)
                        at com.google.firebase.storage.FileDownloadTask.run(Unknown Source)
                        at com.google.firebase.storage.zzr.run(Unknown Source)
                        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
                        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
                        at java.lang.Thread.run(Thread.java:761)
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
E/StorageException: null
                    android.os.RemoteException
                        at com.google.android.gms.internal.ace.<init>(Unknown Source)
                        at com.google.android.gms.internal.ace.zzg(Unknown Source)
                        at com.google.firebase.storage.FileDownloadTask.run(Unknown Source)
                        at com.google.firebase.storage.zzr.run(Unknown Source)
                        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
                        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
                        at java.lang.Thread.run(Thread.java:761)
&#13;
&#13;
&#13;

我的代码有什么问题...我甚至在真实设备上尝试过但仍然无法下载此文件我的存储规则是: service firebase.storage { match /b/{bucket}/o { match /{allPaths=**} { allow read, write:if true } } }

1 个答案:

答案 0 :(得分:0)

根据您的建议,您的Play服务不是最新的。此错误消息告诉您正在进行的操作:

W/GooglePlayServicesUtil: Google Play services out of date.  Requires 11020000 but found 9683470

该消息表明您使用的是客户端库版本11.0.2,但设备上安装了Play服务9.6.83。 Play的版本必须大于或等于客户端库的版本才能使事情发挥作用。