0

I am fetching the data from firebase (Real time database) and displaying it correctly in a recyclerview. This is my code:

My class, StickerPack.class

public class StickerPack implements Parcelable {
    //Vienen de la bd
        public String identifier;
        public String name;
        public String publisher;
        public String trayImageFile;
        public String publisherEmail;
        public String publisherWebsite;
        public String privacyPolicyWebsite;
        public String licenseAgreementWebsite;
        public String imageDataVersion;
        public boolean avoidCache;
    //Se generan dinamicamente
        public String iosAppStoreLink;
        public List<Sticker> stickers;
        public long totalSize;
        public String androidPlayStoreLink;
        public boolean isWhitelisted;

    //Constructores
        public StickerPack(){}
        public StickerPack(String identifier, String name, String publisher, String trayImageFile, String publisherEmail, String publisherWebsite, String privacyPolicyWebsite, String licenseAgreementWebsite, String imageDataVersion, boolean avoidCache) {
            this.identifier = identifier;
            this.name = name;
            this.publisher = publisher;
            this.trayImageFile = trayImageFile;
            this.publisherEmail = publisherEmail;
            this.publisherWebsite = publisherWebsite;
            this.privacyPolicyWebsite = privacyPolicyWebsite;
            this.licenseAgreementWebsite = licenseAgreementWebsite;
            this.imageDataVersion = imageDataVersion;
            this.avoidCache = avoidCache;
        }
        protected StickerPack(Parcel in) {
            identifier = in.readString();
            name = in.readString();
            publisher = in.readString();
            trayImageFile = in.readString();
            publisherEmail = in.readString();
            publisherWebsite = in.readString();
            privacyPolicyWebsite = in.readString();
            licenseAgreementWebsite = in.readString();
            iosAppStoreLink = in.readString();
            stickers = in.createTypedArrayList(Sticker.CREATOR);
            totalSize = in.readLong();
            androidPlayStoreLink = in.readString();
            isWhitelisted = in.readByte() != 0;
            imageDataVersion = in.readString();
            avoidCache = in.readByte() != 0;
        }

    //Getter and Setters are generated by default but i will not show them to not make the post so long
}

And im using the reference and the listeners like this, i'm using two differents ways just for testing and both of them works fine

        FirebaseDatabase firebaseDatabase = FirebaseDatabase.getInstance();
        DatabaseReference databaseReference = firebaseDatabase.getReference("sticker_packs");
        databaseReference.addValueEventListener(new ValueEventListener() {
            @Override
            public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
                stickerPackList = new ArrayList<>();
                for(DataSnapshot ds : dataSnapshot.getChildren()) {
                    StickerPack pack = ds.getValue(StickerPack.class) ;
                    StickerPackFirebase pack2 = ds.getValue(StickerPackFirebase.class) ;

                    GenericTypeIndicator<ArrayList<StickerPack>> t = new GenericTypeIndicator<ArrayList<StickerPack>>() {};
                    ArrayList<StickerPack> spl = dataSnapshot.getValue(t);

                    GenericTypeIndicator<StickerPack> t2 = new GenericTypeIndicator<StickerPack>() {};
                    StickerPack sp = ds.getValue(t2);


                    Log.i("CARTOONLOG", "value1: " + Objects.requireNonNull(ds.getValue()).toString());
                    Log.i("CARTOONLOG", "value2: " + Objects.requireNonNull(pack).name );
                    Log.i("CARTOONLOG", "value2: " + Objects.requireNonNull(pack2).name );


                    if (sp!= null){
                        stickerPackList.add(sp);
                        Log.i("CARTOONLOG", "pack: " + sp.name);
                    }
                }
                setUpRecyclerView(stickerPackList);
            }
            @Override
            public void onCancelled(@NonNull DatabaseError databaseError) {
                Log.i("ERROR FIREBASE", "Error trayendo los datos, firebase snapshot in stickerpacklist");
            }
        });

        DatabaseReference databaseReference2 = firebaseDatabase.getReference("sticker_packs");
        databaseReference2.addChildEventListener(new ChildEventListener() {
            @Override
            public void onChildAdded(@NonNull DataSnapshot dataSnapshot, @Nullable String s) {



                StickerPack pack = dataSnapshot.getValue(StickerPack.class) ;
                StickerPackFirebase pack2 = dataSnapshot.getValue(StickerPackFirebase.class) ;
                Log.i("CARTOONLOGCHILD", "value0: " + Objects.requireNonNull(dataSnapshot.getValue()).toString() + " string: " + s);
                Log.i("CARTOONLOGCHILD", "value1: " + Objects.requireNonNull(pack).name);
                Log.i("CARTOONLOGCHILD", "value2: " + Objects.requireNonNull(pack2).name);


            }
                //The other methods are below this
        });

My data in Firebase looks like this: enter image description here

This are the logs from development enviroment:

enter image description here

And this are the logs from the app downloaded from google play store after i posted on internal testing:

enter image description here

And this is my config in the gradle

buildTypes {
    customDebugType {
        debuggable true
    }
    debug {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
    release {
        minifyEnabled true
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}

Edit:

Maybe this is a usefull information

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'androidx.appcompat:appcompat:1.1.0'

    implementation 'androidx.vectordrawable:vectordrawable-animated:1.1.0'
    implementation 'androidx.browser:browser:1.2.0'
    implementation 'androidx.media:media:1.1.0'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'

    implementation 'com.google.android.material:material:1.1.0'

    implementation 'com.google.firebase:firebase-messaging:20.1.5'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.2.0'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
    implementation 'androidx.recyclerview:recyclerview:1.1.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation 'com.facebook.fresco:fresco:1.10.0'
    implementation 'com.facebook.fresco:webpsupport:1.10.0'
    implementation 'com.facebook.fresco:animated-webp:1.10.0'
    implementation 'com.facebook.fresco:webpsupport:1.10.0'
    implementation 'com.facebook.fresco:animated-base:1.13.0'
    implementation 'com.facebook.fresco:nativeimagetranscoder:1.12.0'
    implementation 'com.google.android.gms:play-services-ads:19.1.0'
    implementation 'com.android.billingclient:billing:2.2.0'

    implementation 'com.google.firebase:firebase-analytics:17.3.0'
    implementation 'com.google.firebase:firebase-ads:19.1.0'


    //implementation 'com.firebaseui:firebase-ui-database:6.2.1'
    implementation 'androidx.multidex:multidex:2.0.1'
    implementation 'com.google.firebase:firebase-database:19.2.1'
    implementation 'com.google.firebase:firebase-storage:19.1.1'
    implementation 'com.firebaseui:firebase-ui-storage:6.2.1'
    implementation 'com.github.bumptech.glide:glide:4.11.0'
    annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0'


}

Edit: Images links replaced by images file

Daniel Vega
  • 141
  • 9
  • 1
    What do you have in your `proguard-rules.pro`? It would be great if you could post the error log if you have any. – Reaz Murshed Apr 26 '20 at 04:33
  • I haven't touched that file, it's all commented. The complete error log is here.[link](https://drive.google.com/open?id=17GduETo_9dP35NBIJAgZGoJjgpkdcYid) **Edit:** The error log is from the app downloaded from google play – Daniel Vega Apr 26 '20 at 05:22
  • Most likely ProGuard is minifying your model classes, which means the app can't read them back from the database. See https://firebase.google.com/docs/database/android/start#proguard – Frank van Puffelen Apr 26 '20 at 06:12
  • @FrankvanPuffelen Yes, that solved the problem, thanks. Can you add this comment as an answer so I can mark it as the correct answer? – Daniel Vega Apr 26 '20 at 15:25

1 Answers1

0

Most likely ProGuard is minifying your model classes, which means the app can't read them back from the database.

See:

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807