Search code examples
firebasegoogle-play-servicesfirebase-storageandroid-things

Can't upload image from RPI 3 to Firebase Storage


I'm trying to upload an image from Raspberry Pi 3 to Firebase Storage but can't do it. I tried different versions of __Firebase_ libraries (11.4.2, 11.6.0, 11.8.0), but I always got the same result. I use OS Build OIM1.171126.016

Firebase dependecies from build.gradle:

compile "com.google.firebase:firebase-core:11.6.0"
compile "com.google.firebase:firebase-auth:11.6.0"
compile "com.google.firebase:firebase-messaging:11.6.0"
compile "com.google.firebase:firebase-firestore:11.6.0"
compile "com.google.firebase:firebase-storage:11.6.0"
compile "com.google.firebase:firebase-crash:11.6.0"

Code for upload image:

private void onPictureTaken(final byte[] imageBytes) {
        if (imageBytes != null) {
            Log.d(TAG, "Picture taken");
            StorageReference storageRef = storage.getReference();
            StorageReference feederRef = storageRef.child("test/test.jpg");

            feederRef.putBytes(imageBytes).addOnFailureListener(new OnFailureListener() {
                @Override
                public void onFailure(@NonNull Exception exception) {
                    // Handle unsuccessful uploads
                    Log.e(TAG, exception.getMessage(), exception);
                }
            }).addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
                @Override
                public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
                    Uri downloadUrl = taskSnapshot.getDownloadUrl();
                    Log.d(TAG, "downaload uri = " + downloadUrl);
                }
            });
        }
    }

Log:

W/GooglePlayServicesUtil: Google Play services is missing.
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:176)
                             at com.google.android.gms.internal.zzewy.<init>(Unknown Source:18)
                             at com.google.android.gms.internal.zzewy.zzh(Unknown Source:13)
                             at com.google.firebase.storage.StorageReference.zzcjq(Unknown Source:8)
                             at com.google.firebase.storage.UploadTask.run(Unknown Source:105)
                             at com.google.firebase.storage.zzr.run(Unknown Source:2)
                             at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
                             at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
                             at java.lang.Thread.run(Thread.java:764)
E/UploadTask: Unable to create a network request from metadata
              android.os.RemoteException
                  at com.google.android.gms.internal.zzewy.<init>(Unknown Source:85)
                  at com.google.android.gms.internal.zzewy.zzh(Unknown Source:13)
                  at com.google.firebase.storage.StorageReference.zzcjq(Unknown Source:8)
                  at com.google.firebase.storage.UploadTask.run(Unknown Source:105)
                  at com.google.firebase.storage.zzr.run(Unknown Source:2)
                  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
                  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
                  at java.lang.Thread.run(Thread.java:764)
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.zzewy.<init>(Unknown Source:85)
                        at com.google.android.gms.internal.zzewy.zzh(Unknown Source:13)
                        at com.google.firebase.storage.StorageReference.zzcjq(Unknown Source:8)
                        at com.google.firebase.storage.UploadTask.run(Unknown Source:105)
                        at com.google.firebase.storage.zzr.run(Unknown Source:2)
                        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
                        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
                        at java.lang.Thread.run(Thread.java:764)
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.zzewy.<init>(Unknown Source:85)
                        at com.google.android.gms.internal.zzewy.zzh(Unknown Source:13)
                        at com.google.firebase.storage.StorageReference.zzcjq(Unknown Source:8)
                        at com.google.firebase.storage.UploadTask.run(Unknown Source:105)
                        at com.google.firebase.storage.zzr.run(Unknown Source:2)
                        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
                        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
                        at java.lang.Thread.run(Thread.java:764)
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.zzewy.<init>(Unknown Source:85)
                        at com.google.android.gms.internal.zzewy.zzh(Unknown Source:13)
                        at com.google.firebase.storage.StorageReference.zzcjq(Unknown Source:8)
                        at com.google.firebase.storage.UploadTask.run(Unknown Source:105)
                        at com.google.firebase.storage.zzr.run(Unknown Source:2)
                        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
                        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
                        at java.lang.Thread.run(Thread.java:764)

Rule in Firebase Storage:

service firebase.storage {
  match /b/my-app.appspot.com/o {
    match /{allPaths=**} {
      allow read, write;
    }
  }
}

What is wrong with my code?


Solution

  • According to the logcat messages:

    W/GooglePlayServicesUtil: Google Play services is missing.
    

    Check if package com.google.android.gms is installed in the system with

    adb shell pm list packages
    

    In case the package is missing try getting a new Android Things Bundle from the console and reflashing the image.