How to upload file to firebase file storage in Android Studio?
I am creating an android application in which I am using a firebase database to store files. But I get an error and after this error my program continues to run but never goes into onsuccessListener()
. Please help me with this. My code is like this
Intent intent=new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(intent,gallery_intent);
Code for StartActivityForResult.
if(requestCode==gallery_intent && resultCode==RESULT_OK){
uri=data.getData();
progressDialog.setMessage("Uploading...");
progressDialog.show();
FirebaseStorage storage=FirebaseStorage.getInstance();
StorageReference storageReference=storage.getReference().child("Ad Posts");
try {
storageReference.putFile(uri).addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
@Override
public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
Toast.makeText(ServiceProvider.this, "Ad Successfully added to the database", Toast.LENGTH_SHORT).show();
progressDialog.dismiss();
}
});
}catch (Exception e){
}
}
The error I am getting.
E/NetworkRqFactoryProxy: NetworkRequestFactoryProxy failed with a RemoteException:
com.google.android.gms.dynamite.DynamiteModule$zza: 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.zzbud.<init>(Unknown Source)
at com.google.android.gms.internal.zzbud.zzj(Unknown Source)
at com.google.firebase.storage.StorageReference.zzacy(Unknown Source)
at com.google.firebase.storage.UploadTask.zzacO(Unknown Source)
at com.google.firebase.storage.UploadTask.run(Unknown Source)
at com.google.firebase.storage.StorageTask$8.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/UploadTask: Unable to create a network request from metadata
android.os.RemoteException
at com.google.android.gms.internal.zzbud.<init>(Unknown Source)
at com.google.android.gms.internal.zzbud.zzj(Unknown Source)
at com.google.firebase.storage.StorageReference.zzacy(Unknown Source)
at com.google.firebase.storage.UploadTask.zzacO(Unknown Source)
at com.google.firebase.storage.UploadTask.run(Unknown Source)
at com.google.firebase.storage.StorageTask$8.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.zzbud.<init>(Unknown Source)
at com.google.android.gms.internal.zzbud.zzj(Unknown Source)
at com.google.firebase.storage.StorageReference.zzacy(Unknown Source)
at com.google.firebase.storage.UploadTask.zzacO(Unknown Source)
at com.google.firebase.storage.UploadTask.run(Unknown Source)
at com.google.firebase.storage.StorageTask$8.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.zzbud.<init>(Unknown Source)
at com.google.android.gms.internal.zzbud.zzj(Unknown Source)
at com.google.firebase.storage.StorageReference.zzacy(Unknown Source)
at com.google.firebase.storage.UploadTask.zzacO(Unknown Source)
at com.google.firebase.storage.UploadTask.run(Unknown Source)
at com.google.firebase.storage.StorageTask$8.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)
+3
source to share