Ad
How To Retrieve Firebase Storage Images In Release Mode?
I use the following code to retrieve images from Firebase Storage
using Firebase Database
:
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState)
{
firebaseDatabase = FirebaseDatabase.getInstance();
databaseReference = firebaseDatabase.getReference("images");
}
@Override
public void onStart()
{
super.onStart();
ValueEventListener listener = new ValueEventListener()
{
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot)
{
for (DataSnapshot singleImage: dataSnapshot.getChildren())
{
SharableImageClass sharableImage = singleImage.getValue(SharableImageClass.class);
imagesList.add(sharableImage.getSharableImage());
}
ImagesAdapter addapter = new ImagesAdapter(getActivity(), imagesList);
imagesRecyclerView.setAdapter(addapter);
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError)
{
Toast.makeText(getActivity(), "Error.. Cannot connect to Internet", Toast.LENGTH_SHORT).show();
}
};
databaseReference.addValueEventListener(listener);
}
This is the SharableImageClass.class:
public class SharableImageClass
{
public String sharableImage;
public SharableImageClass() {
}
public SharableImageClass(String sharableImage) {
this.sharableImage = sharableImage;
}
public String getSharableImage() {
return sharableImage;
}
public void setSharableImage(String sharableImage) {
this.sharableImage = sharableImage;
}
}
This is the part of the ImagesAdapter where I display the image in an ImageView using Picasso:
@Override
public void onBindViewHolder(@NonNull ImagesViewHolder holder, int position)
{
Picasso.get()
.load(imagesList.get(position).toString())
.fit()
.into(holder.imagesImageView);
}
Everything works fine when I run this code in the Debug mode. But, when I create a signed apk and run the app, it shows the following exception:
No setter/field for sharableImage found on class com.ksdfunapps.ksdstickersforchat.a
What is wrong with the code? This is the structure of Firebase database:
Ad
Answer
add proguard rules in proguard file than build your signed APK
# Add this global rule
-keepattributes Signature
# This rule will properly ProGuard all the model classes in
# the package com.yourcompany.models. Modify to fit the structure
# of your app.
-keepclassmembers class com.yourcompany.models.** {
*;
}
For more description see this link
Ad
source: stackoverflow.com
Related Questions
- → should I choose reactjs+f7 or f7+vue.js?
- → Phonegap Android write to sd card
- → Local reference jquery script in nanohttpd (Android)
- → Click to navigate on mobile devices
- → How to allow api access to android or ios app only(laravel)?
- → Access the Camera and CameraRoll on Android using React Native?
- → React native change listening port
- → What is the default unit of style in React Native?
- → Google play market autocomplete icon
- → Warning: Each child in an array or iterator should have a unique "key" prop. Check the render method of `ListView`
- → Using Laravel with Genymotion
- → react native using like web-based ajax function
- → react native pdf View
Ad