Reputation: 735
I am quite new to Java and I am currently trying to use the Firebase Admin SDK with my application.
I am using Eclipse with the Maven plugin.
I have included this dependency in my Maven pom.xml file
<dependency>
<groupId>com.google.firebase</groupId>
<artifactId>firebase-admin</artifactId>
<version>4.0.3</version>
</dependency>
After that, I made a new application under src/main/java and I tried to initialize the SDK with the code below, as the official Google Document asked me to.
package com.vogella.maven.quickstart;
import com.google.firebase.FirebaseOptions;
public class App {
public static void main( String[] args )
{
/*Firebase SDKをinitializeするために*/
FirebaseOptions options = new FirebaseOptions.Builder();
} }
However, I am getting an error saying that I have to change the code to
Builder options = new FirebaseOptions.Builder()
Is the Google official document wrong?
Upvotes: 2
Views: 1565
Reputation: 192023
Looks like you didn't copy the rest of the code
FirebaseOptions options = new FirebaseOptions.Builder() .setServiceAccount(new FileInputStream("path/to/serviceAccountKey.json")) .setDatabaseUrl("https://<DATABASE_NAME>.firebaseio.com/") .build(); FirebaseApp.initializeApp(options);
Your error is that obviously a FirebaseOptions
class cannot be assigned to a new FirebaseOptions.Builder()
.
You must build()
the Builder
Upvotes: 1