Firebase Firestore变量名称已更改 [英] Firebase firestore variable name changed

查看:77
本文介绍了Firebase Firestore变量名称已更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的firestore变量通过其他名称保存在cloud firestore中.我认为这与proguard有关,但我不明白.

My firestore variables are saved by other names in cloud firestore. I think this is related to proguard, but I am not getting it.

以下是我的用户名.

public String id;
public String name;
public String number;
public String profilePic;
public String shopPic;

以及以下是屏幕截图,这些内容保存在firestore中.

and following is the screenshot, what is saved on firestore.

这是一些相关的代码,非常简单

Here is some related code, which is very simple

        FirestoreUrls.get().getAccountsCollection()
                .document().set(binding.getUser()).addOnCompleteListener(new OnCompleteListener<Void>() {
            @Override
            public void onComplete(@NonNull Task<Void> task) {
                hideProgressBar();
                handleFirebaseException(getClass(), task, true);
            }
        });

推荐答案

您正在遇到此问题,因为您正在使用Proguard进行安全保护,这会乱码代码,以便其他人在创建应用程序的APK后无法立即看到它.对于Firebase,这也可用.要解决此问题,请在您的build.gradle文件中添加以下代码行:

You are experiencing this problem because you are using Proguard for security, which shuffles the code so others cannot see it right after you create the app's APK. This is also available in the case of Firebase. To solve this, please add the following lines of code in your build.gradle file:

buildTypes {
    release {
        minifyEnabled true
        shrinkResources true
        proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
    }
}

然后在项目的Proguard文件中添加以下规则,以通过使用您自己的包名称替换包名称来防止该行为:

Then add the following rules in your project's Proguard file to prevent that behavior by replacing the package name with your own package name:

-keepattributes Signature //Global rule

-keepclassmembers class com.example.YourModelClass.** {
  *;
}

请检查文档以获取更多信息:

Please check the docs for more information:

这篇关于Firebase Firestore变量名称已更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆