Firebase:添加compile&com.google.firebase:firebase-server-sdk:[3.0.0,)' dependencier

时间:2016-06-28 00:03:29

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

当我添加编译com.google.firebase:firebase-server-sdk:[3.0.0,]'时,我的应用正在工作。添加firebase自定义outh

错误在此代码中有效,

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

2 个答案:

答案 0 :(得分:1)

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

按照https://www.firebase.com/docs/android/quickstart.html

上的Android教程进行操作

答案 1 :(得分:0)

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

尝试将代码更改为:

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

    }
}

检查getApp()文档here