Nasib
Nasib

Reputation: 1579

How to protect classes from being removed by MINIFY_ENABLED?

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'
}

Upvotes: 5

Views: 4473

Answers (1)

Nasib
Nasib

Reputation: 1579

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

Upvotes: 8

Related Questions