How to display or get an image from Firebase storage

I'm new to Android and I have a problem upon displaying an image from FirebaseStorage.

This is my code in MainActivity.java:

ImageView image = (ImageView) findViewById(R.id.profilePic_image_view);

mStorage = FirebaseStorage.getInstance().getReference();
Uri downloadURI = mStorage.child("circleako.png").getDownloadUrl().getResult();


Inside my gradle are these:

compile 'com.google.firebase:firebase-database:10.0.1'
compile 'com.google.firebase:firebase-storage:9.6.1'
compile 'com.google.android.gms:play-services-base:10.0.1'
compile 'com.google.android.gms:play-services-maps:10.0.1'
compile 'com.google.android.gms:play-services-location:10.0.1'
compile 'com.google.android.gms:play-services-analytics:10.0.1'
compile 'com.squareup.picasso:picasso:2.5.2'
testCompile 'junit:junit:4.12'

This is the error:

01-19 16:35:09.998 7334-7334/com.example.asuspc.timeclock E/AndroidRuntime: FATAL EXCEPTION: main

Process: com.example.asuspc.timeclock, PID: 7334
  java.lang.NoSuchMethodError: No static method zzy(Ljava/lang/Object;)Ljava/lang/Object;
  in class Lcom/google/android/gms/common/internal/zzac; or its super classes
  (declaration of 'com.google.android.gms.common.internal.zzac' appears in
at com.google.android.gms.internal.zzann.zzug(Unknown Source)
at com.google.android.gms.internal.zzann.zzuf(Unknown Source)
at com.google.firebase.storage.StorageReference.child(Unknown Source)
at com.example.asuspc.timeclock.MainActivity.onCreate(MainActivity.java:198)
at android.app.Activity.performCreate(Activity.java:6323)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1108)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2387)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2494)
at android.app.ActivityThread.access$900(ActivityThread.java:153)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1347)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5451)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)


You can to use Glide. With Glide you can show animated gifs too.

String urlImage = "You URL Image";


in gradle-app put:

compile 'com.github.bumptech.glide:glide:3.7.0'

Clean your project and do a full reinstall of the app on the device, it seems to be an issue with instant-run.

Also, I'd recommend using Glide instead of Picasso with Firebase Storage (or cases where you load images from a URL). Picasso doesn't handle EXIF well, so in certain conditions it can cause issues such as orientation problems for images.


mStorage.child("circleako.png").getDownloadUrl().addOnSuccessListener(new OnSuccessListener<Uri>() {
    public void onSuccess(Uri uri) {
    }).addOnFailureListener(new OnFailureListener() {
        public void onFailure(@NonNull Exception exception) {
            // Handle any errors

受限制的 HTML

  • 允许的HTML标签:<a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id>
  • 自动断行和分段。
  • 网页和电子邮件地址自动转换为链接。

  • Write image file to Firebase Storage from HTTP function
    I am trying to write an image Firebase Storage via a Cloud Function (for more suitable write access). My current attempt is to read the file object on the client, send it (the data) to an http firebase function, and then save it to storage from there. After saving the file successfully, I try using the download url as an img src value, but the file does not display. I also see an error in the Storage console (Error loading preview) when attempting to view the file. If I save the data in Storage as base64, I can copy the contents of the file into the img src attribute, and it displays fine
  • 如何在Firebase应用程序中获取Cloud Storage中所有文件的列表?(How to get a list of all files in Cloud Storage in a Firebase app?)
    问题 我正在上载图片,一切都很好,但是我有100张图片,我想在View显示所有View ,因为我在文件夹中获得了完整的图片列表,因此找不到任何API这项工作。 回答1 由于适用于JavaScript的Firebase SDK发行版6.1,iOS发行版6.4和Android发行版18.1均具有列出文件的方法。 到目前为止,该文档还很少,所以我建议查看Rosário的答案以获取详细信息。 先前的答案,因为这种方法有时仍然有用: Firebase SDK中目前没有API调用可列出应用程序内Cloud Storage文件夹中的所有文件。 如果需要这种功能,则应将文件的元数据(例如下载URL)存储在可以列出它们的位置。 Firebase实时数据库和Cloud Firestore非常适合此操作,使您也可以轻松地与其他人共享URL。 您可以在FriendlyPix示例应用程序中找到一个很好的示例(但有些涉及)。 Web版本的相关代码在这里,但是还有iOS和Android的版本。 回答2 截至2019年5月,适用于Cloud Storage的Firebase SDK 6.1.0版本现在支持列出存储桶中的所有对象。 您只需要在Reference调用listAll() : // Since you mentioned your images are in a folder, // we'll
  • 将图片从URL上传到Firebase存储(Upload image from URL to Firebase Storage)
    问题 我想知道如何通过URL而不是输入将文件上传到Firebase的存储中(例如)。 我正在从网站上抓取图像并检索其URL。 我想通过一个foreach语句传递这些URL,然后将它们上传到Firebase的存储中。 现在,我有使用以下代码的firebase upload-via-input输入: var auth = firebase.auth(); var storageRef = firebase.storage().ref(); function handleFileSelect(evt) { evt.stopPropagation(); evt.preventDefault(); var file = evt.target.files[0]; var metadata = { 'contentType': file.type }; // Push to child path. var uploadTask = storageRef.child('images/' + file.name).put(file, metadata); // Listen for errors and completion of the upload. // [START oncomplete] uploadTask.on('state_changed', null, function(error
  • How to Display Firebase Storage Images in GridView
    I am New to Android , I am learning about gridview. I want to display a list of images from drawables into a gridview but I don't know how to display images from Firebase Storage in a gridview. I seen Many Tutorials and and I tried lot of Stackoverflow Answers but I cannot get what i need I created a New Folder in Firebase Storage and i upload 6 images there and I want to display all the 6 images in gridview. Here is My Code of how I display images From drawable and I don't know how to load that url and in glide I was totally confused and messed myself public class NewListCreate extends
  • Firebase User Uploads and Profile Pictures
    Hello looking for some help, I currently have some JavaScript code that allows a signed in user to upload an image to Firebase storage. I want the image that they upload to be their profile picture, however I don't seem to be able to link the uploaded image back to the specific user? It works, I can see the uploaded image in the console, but nothing to identify what user uploaded it. //Upload Profile Picture //Altered code from: Firebase Youtube Channel. //Get Elements var uploader = document.getElementById('uploader'); var fileButton = document.getElementById('fileButton'); //Listen for file
  • 从Google Firebase存储本地缓存图像(Cache images local, from google firebase storage)
    问题 我正在寻找一种方法,可以从Google Firebase平台上的存储中缓存图像。 目前,我可以下载图像并将其显示给用户,但是即使没有Internet连接,也无法缓存和访问图像。 可以脱机访问数据库。 所以我想,也将有一种存储方式。 我不想将每个图像都下载到存储设备,因为那我需要每次检查一次,如果图像仍然是最新的,则可能会更改它。 以下是我可以找到的一些链接,但我的问题没有答案。 也许有人知道一种解决方法,或一种方法来完成它。 谢谢! 下载文件:https://firebase.google.com/docs/storage/android/download-files 缓存(离线)数据库:https://firebase.google.com/docs/database/android/offline-capabilities 更新1 这是我使用毕加索“缓存”文件的方式,我添加了活动,此举与下载有关: Picasso.with(getApplicationContext()) .load(uri.toString()) .networkPolicy(NetworkPolicy.OFFLINE) .into(image1); 欢迎任何帮助。 谢谢! 回答1 恐怕Firebase SDK本身不会提供图像缓存。 但是,有几个很棒的库可以为您做这件事。 他们下载图像
  • Flutter Load Image from Firebase Storage
    I see there are a lot of examples on how to upload an image using flutter to firebase storage but nothing on actually downloading/reading/displaying one that's already been uploaded. In Android, I simply used Glide to display the images, how do I do so in Flutter? Do I use the NetworkImage class and if so, how do I first get the url of the image stored in Storage?
  • How to delete a child from Firebase (Swift)
    I've been following a tutorial on making an instragram-esque app, and I'm having a lot of trouble figuring out how to delete a post, both from Firebase and from the feed. The image that the user selects or takes is uploaded to Firebase database with this function: func uploadToFirebase() { AppDelegate.instance().showActivityIndicator() let uid = FIRAuth.auth()!.currentUser!.uid let ref = FIRDatabase.database().reference() let storage = FIRStorage.storage().reference(forURL: "gs://cloudcamerattt.appspot.com") let key = ref.child("posts").childByAutoId().key let imageRef = storage.child("posts")
  • How to check if a file exists in Firebase storage from your android application?
    I am developing android application where a user clicks image, it gets stored in firebase, cloud functions process this image and stores the output back in the firebase in the form of text file. In order to display the output in android, application keeps checking for output file if it exists or not. If yes, then it displays the output in the application. If no, I have to keep waiting for the file till it is available. I'm unable to find any documentation for checking if any file is exists in Firebase or not. Any help or pointers will be helpful. Thanks.
  • Getting 403 Forbidden error when trying to load image from Firebase Storage
    I'm using firebase storage to store and load images for users on my android app. All users must be authenticated before using it. Occasionally, some user profile images are not showing and throwing "403 Forbidden" error. Those images were displaying before, I'm not sure why they stop working. i'm using the following rules on my firebase storage: service firebase.storage { match /b/<storage_address>.appspot.com/o { match /{allPaths=**} { allow read: if request.auth != null; allow write: if request.auth != null; } } } if i change the read rule to allow read; all the images are working properly
  • Display images from firebase storage in html img tags
    I'm attempting to display an image from firebase into html img tags, but it fails to retrieve the image. Javascript code: var storageRef = firebase.storage().ref(); var spaceRef = storageRef.child('images/photo_1.png'); var path = spaceRef.fullPath; var gsReference = storage.refFromURL('gs://test.appspot.com') storageRef.child('images/photo_1.png').getDownloadURL().then(function(url) { var test = url; }).catch(function(error) { }); html code: <img src="test" height="125" width="50"/>
  • Swift2从Firebase检索图像(Swift2 retrieving images from Firebase)
    问题 我正在尝试从Firebase读取/显示图像。 我首先对图像进行编码,然后将此编码后的字符串发布到Firebase。 运行良好。 当我尝试从Firebase解码编码的字符串并将其转换为图像时,出现了nil值异常。 这就是我将图像保存到Firebase的方式 var base64String: NSString! func imagePickerController(picker: UIImagePickerController, didFinishPickingImage image: UIImage, editingInfo: [String : AnyObject]?) { self.dismissViewControllerAnimated(true, completion: nil) imageToPost.image = image var uploadImage = image as! UIImage var imageData = UIImagePNGRepresentation(uploadImage)! self.base64String = imageData.base64EncodedStringWithOptions(NSDataBase64EncodingOptions.Encoding64CharacterLineLength) let ref =
  • Firebase storage slow when delivering public images
    I'm using firebase storage to upload avatars (original.jpg). In a node.js background process I resize them with gm and then put them back in my firebase bucket. These pictures are publicly readable, see my storage rules : service firebase.storage { match /b/xxx.appspot.com/o { match /images { match /{allImages=**} { allow read; } match /{userId}/avatar/original.jpg { allow write: if request.auth.uid == userId; } } } } I store the url of images in firebase database ex: https://firebasestorage.googleapis.com/v0/b/xxx.appspot.com/o/images%2Fyyy%2Favatar%2Fzzz-small.jpg?alt=media That I retrieved
  • Understanding Firebase Storage tokens
    I'm trying to understand how tokens work in Firebase Storage. Whenever my web app uploads an image to FS it adds a token to its public url. The problem is whenever you upload that same image file to another part of the web app, it seems like you don't get another file, but a different token for the file url that was already uploaded, thus rendering a 403 error for the previous registered image display. Is there a way to solve this? Example: storageRef.put(picture.jpg); uploadTask.snapshot.downloadURL // returns something like https://firebasestorage.googleapis.com/v0/b/<your-app>/o/picture.jpg
  • Firebase Storage getDownloadUrl's token validity
    I have a question regarding the "token" in the url(&token=) when using getDownloadUrl of FirebaseStorage. https://firebasestorage.googleapis.com/v0/b/someapplication.appspot.com/o/images%2Fsample.png?alt=media&token=123456 From docs, it says that it returns a "long lived" download url https://firebase.google.com/docs/reference/js/firebase.storage.Reference#getDownloadURL Problem is, im saving the downloadUrl in FirebaseDatabase like -chatroom - c1 - m1 -message: "Sent a photo" -photoUrl: downloadUrl here From what i understand it is not a lifetime token so at some point in time the token will
  • FirebaseStorage:如何删除目录(FirebaseStorage: How to Delete Directory)
    问题 当我尝试删除目录时,FirebaseStorage始终返回错误400 ,即类似以下内容始终返回错误400 。 let storageRef = FIRStorage.storage().reference().child("path/to/directory") storageRef.deleteWithCompletion { (error) in print("error: \(error)") // always prints error code 400 } 但是,删除文件可以正常工作,例如不会返回错误: let storageRef = FIRStorage.storage().reference().child("path/to/file.jpg") storageRef.deleteWithCompletion { (error) in print("error: \(error)") // works fine, error is nil } 我在这里可能做错了什么? 我不认为FirebaseStorage不支持它,因为从目录中一个接一个地删除文件会很la脚(特别是如果所述目录中有100或1000个这样的目录)。 回答1 从安全的Google云功能的上下文中-您可以使用Google Cloud Storage npm程序包(又名Google Cloud
  • Upload profile image for a user Firebase
    I am trying to add an image to the user information in the real time database(firebase) for android. I have uploaded the image on the firebase storage but how will I be able to add the image in the database for that user? Code Below: //inside onCreate() method img.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent i=new Intent(Intent.ACTION_PICK); i.setType("image/*"); startActivityForResult(i,request_code); } }); Here I am clicking on the imageview, so I will be able to change it and get an image from the gallery. Here I authenticate the user and
  • firebase function get download url after successfully save image to firebase cloud storage
    I'm having problem getting download url in firebase function after saving image to cloud storage. Below is my firebase http function in typescript to save base64 string to jpeg in firebase cloud storage. when i log result, it always empty. I follow this link to get download url "Get Public URL from file uploaded with firebase-admin". But it give me following error:"SigningError: Identity and Access Management (IAM) API has not been used in project 81673989436 before or it is disabled." And couldn't find simple example to follow. My plan is to update my firestore table, once uploaded to cloud
  • Firebase使用电子邮件,密码,显示名称和照片网址创建用户(Firebase create user with email, password, display name and photo url)
    问题 根据Firebase网站,我正在使用以下代码创建新用户: firebase.auth().createUserWithEmailAndPassword(email, password).catch(function(error) {}); 创建新用户时,如何在“身份验证”中添加显示名称和照片网址? 此链接显示从Auth中的身份提供者返回的受支持的用户数据。 回答1 您可以使用FIRUserProfileChangeRequest类来更新您的配置文件。 let user = FIRAuth.auth()?.currentUser if let user = user { let changeRequest = user.profileChangeRequest() changeRequest.displayName = "Jane Q. User" changeRequest.photoURL = NSURL(string: "https://example.com/jane-q-user/profile.jpg") changeRequest.commitChangesWithCompletion { error in if let error = error { // An error happened. } else { // Profile updated. } } }
  • firebase.storage() is not a function in jest test cases
    I am using Jest to test my firebase functions. This is all in the browser, so I don't have any conflicts with firebase on the server side. When I use firebase.auth() or firebase.database() everything works fine. When I try to use firebase.storage() my tests fail. Here is my firebase import and initialization: import firebase from 'firebase'; import config from '../config'; export const firebaseApp = firebase.initializeApp(config.FIREBASE_CONFIG); export const firebaseAuth = firebaseApp.auth(); export const firebaseDb = firebaseApp.database(); I have an imageUtils file that has an upload