首页 > 解决方案 > Firebase Realtime 在调试模式下工作,而不是在运行应用模式下工作

问题描述

我有一个恢复订阅的代码。BillingClient 在启动我的应用程序时检查并确认付款是否已确认。确认付款后,我正在尝试将数据打印到 Firebase Realtime。这在调试模式下工作正常,但是当我在应用程序运行模式下运行它时,它不会将此信息打印到 firebase。当我在调试模式下运行它并勾选 addValue 时,代码可以完美运行。我应该怎么办?请帮我。

谢谢

 public void addValue(String productid, String token, String orderid, String signatur, String deviceId, String getUID, Long islemtime, String islem, String timem, String orjiJson) {
        String key = mDatabaseReference.child("/subs/").push().getKey();
        String languagename = Locale.getDefault().getDisplayLanguage();
        Integer status = 0;
        Subscriptions subscriptions = new Subscriptions(productid, token, orderid, getUID, signatur, deviceId, languagename, islemtime, islem, timem, orjiJson, status);
        mDatabaseReference.child("/subs/").child(key).setValue(subscriptions, new DatabaseReference.CompletionListener() {
            @Override
            public void onComplete(DatabaseError databaseError, DatabaseReference databaseReference) {
                hideProgressDialogStatic();
                Intent n_act = new Intent(MyApplication.getInstance(), subfinish.class);
                n_act.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                MyApplication.getInstance().startActivity(n_act);

            }
        });
    }
}

标签: javaandroidfirebasefirebase-realtime-database

解决方案


如果您在发布版本中使用 ProGuard 或任何混淆,则需要@Keep在您的类上使用注释。

例子:

import androidx.annotation.Keep

@Keep
public class YourClass {}

推荐阅读