【问题标题】:Firebase:Issue with adding compile 'com.google.firebase:firebase-server-sdk:[3.0.0,)' dependencierFirebase:添加 compile 'com.google.firebase:firebase-server-sdk:[3.0.0,)' 依赖项的问题
【发布时间】:2016-06-28 00:03:29
【问题描述】:

当我添加 compile 'com.google.firebase:firebase-server-sdk:[3.0.0,)' 以添加 firebase 自定义输出时,我的应用程序运行正常

此代码中的错误有效,

public void onCreate(){
        super.onCreate();
        if (!FirebaseApp.getApps(this).isEmpty()) {
            FirebaseDatabase.getInstance().setPersistenceEnabled(true);
        }

        }
}
Error:(23, 25) error: method getApps in class FirebaseApp cannot be applied to given types;
required: no arguments
found: Application
reason: actual and formal argument lists differ in length............,

还有这个警告。

org.apache.httpcomponents:httpclient:4.0.1 is ignored for release as it may be conflicting with the internal version provided by Android.
         In case of problem, please repackage it with jarjar to change the class packages

【问题讨论】:

    标签: android firebase firebase-realtime-database firebase-authentication


    【解决方案1】:

    您正在导入 firebase 服务器 SDK。您需要导入 Android 版本。

    按照https://www.firebase.com/docs/android/quickstart.html的Android教程进行操作

    【讨论】:

    • 好收获!您永远不应在客户端应用程序中运行自定义身份验证代码。创建自定义令牌需要访问您的应用程序的密钥,该密钥不应在客户端代码中公开。
    【解决方案2】:

    可能从错误消息中不言而喻,您的方法 FirebaseApp.getApp() 不需要任何参数。

    尝试将代码更改为:

    public void onCreate(){
        super.onCreate();
        if (!FirebaseApp.getApps().isEmpty()) {
            FirebaseDatabase.getInstance().setPersistenceEnabled(true);
        }
    
        }
    }
    

    查看 getApp() 文档here

    【讨论】:

      猜你喜欢
      • 2020-01-04
      • 1970-01-01
      • 1970-01-01
      • 2019-08-23
      • 2020-05-19
      • 2019-09-10
      • 2013-03-21
      • 2019-11-24
      • 1970-01-01
      相关资源
      最近更新 更多