1

My app is working okey byt when I add compile 'com.google.firebase:firebase-server-sdk:[3.0.0,)' to add firebase custom outh

The error works in this code,

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............,

and also this warning.

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 Answers 2

1

You are importing the firebase server SDK. You need to import the Android version.

Follow the Android tutorial at https://www.firebase.com/docs/android/quickstart.html

Sign up to request clarification or add additional context in comments.

1 Comment

Good catch! You should never run the custom authentication code in the client app. Creating a custom token requires access to your app's secret, which should never be exposed in client-side code.
0

Maybe its self-evident from the error message that your method FirebaseApp.getApp() does not need any argument.

Try changing the code to:

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

    }
}

Check getApp() documentation here

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.