Я пытаюсь подключиться к базе данных firebase из моего кода Java. Но я сталкиваюсь с ошибкой ниже,
java.io.IOException: Error reading credentials from stream, 'type' field not specified.
at com.google.auth.oauth2.GoogleCredentials.fromStream(GoogleCredentials.java:156)
at com.google.auth.oauth2.GoogleCredentials.fromStream(GoogleCredentials.java:129)
at www.app.main(app.java:30)
Мой код:
public class app {
public static void main(String[] args) {
// TODO Auto-generated method stub
final String json="E:\\\\Thesis\\\\4.2\\\\Resources\\\\rakib\\\\google-services-json\\\\google-services.json";
try {
InputStream inputStream = new FileInputStream(json);
FirebaseOptions options = new FirebaseOptions.Builder()
.setDatabaseUrl("https://database-ff395.firebaseio.com/")
.setCredentials(GoogleCredentials.fromStream(inputStream))
.build();
FirebaseApp.initializeApp(options);
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch(IOException e) {
e.printStackTrace();
}
}
}
Строка ошибки .setCredentials(GoogleCredentials.fromStream(inputStream))
Ошибка говорит, что тип не указан, но я ужеуказал тип для inputstream
как InputStream Как я могу решить эту проблему?
Полный код здесь: https://pastebin.com/wmwFRF79