5

I am using FirebaseFirestore in my project. When i am in debug mode, minifyEnabled FALSE, the app runs just fine, but when I build a signed .apk, minifyEnabled TRUE, it doesn't work as I expect. i.e it doesn't load data from firebase Firestore.

What KEEP statments should i write to exlude FIREBASE FIRESTORE and Glide classes from minifying ?

dependencies {
implementation 'com.android.support:appcompat-v7:28.0.0'

implementation 'com.google.firebase:firebase-core:16.0.9'
implementation 'com.google.firebase:firebase-firestore:19.0.0'
implementation 'com.google.firebase:firebase-ads:17.2.0'
}
Nasib
  • 1,173
  • 1
  • 13
  • 23
  • Problem will be with your release ProGuard configuration. Post it here. – Tomas Ivan Jul 09 '19 at 11:16
  • See this: https://stackoverflow.com/questions/4830474/how-to-keep-exclude-a-particular-package-path-when-using-proguard – Dzhuneyt Jul 09 '19 at 12:17
  • @Tomas, where can i find the release ProGuard configurations ? – Nasib Jul 09 '19 at 13:10
  • @Nasib If you need to know basics, then look here: https://guides.codepath.com/android/Configuring-ProGuard – Tomas Ivan Jul 09 '19 at 14:16
  • @Tomas, thank you my Proguard configuration is `buildTypes { release { minifyEnabled false shrinkResources false proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } }` – Nasib Jul 10 '19 at 06:12
  • @Nasib now copy here content of your 'proguard-rules.pro' file. And edit your question. – Tomas Ivan Jul 10 '19 at 06:19
  • @TomasIvan i've edited my question. there's the contents of 'proguard-rules.pro' please check it – Nasib Jul 10 '19 at 07:43
  • basics: https://github.com/bumptech/glide#proguard and https://firebase.google.com/docs/database/android/start#proguard – Tomas Ivan Jul 15 '19 at 12:28
  • 1
    Everytime you use some 3rd party library and use proguard, then take a look at project websites and look for proguard rules. – Tomas Ivan Jul 15 '19 at 12:30

1 Answers1

8

SOLUTION: the ProGuard renames almost every class. And it renamed my model class (pojo), that which i used for encapsulating data for the Firestore, and firestore only recognized that name, in my case, "Upload".

but when the proguard renamed it, it named the "Upload" class as " j " and, the firestore SDK didn't recognize "j".

that was the problem.

i added "@Keep" annotation with "Upload" class and my problem was solved.

@Keep
public class Upload{
.....
.....
}

Suggestion: You should also add this @Keep annotation for Room Entity Classes and Retrofit data Classes

Nasib
  • 1,173
  • 1
  • 13
  • 23