J'utilise ceci :
FileInputStream serviceAccount;
try {
serviceAccount = new FileInputStream("firebase_key.json");
} catch (FileNotFoundException e) {
System.out.println(e.getMessage());
return;
}
System.out.println("Reached here!");
FirebaseOptions options = new FirebaseOptions.Builder()
.setCredential(FirebaseCredentials.fromCertificate(serviceAccount))
.setDatabaseUrl("https://*.firebaseio.com/")
.build();
FirebaseApp.initializeApp(options);
Cependant, l'application se bloque avec un java.lang.NoClassDefFoundError for FirebaseOptions$Builder
Mon build.gradle
:
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.11'
compile 'com.google.firebase:firebase-admin:4.1.1'
}
J'utilise IntelliJ.
Logcat :
Exception in thread "main" java.lang.NoClassDefFoundError: com/google/firebase/FirebaseOptions$Builder
10:57:43 AM web.1 | at com.x.*.TokenGenerator.main(TokenGenerator.java:26)
10:57:43 AM web.1 | Caused by: java.lang.ClassNotFoundException: com.google.firebase.FirebaseOptions$Builder
10:57:43 AM web.1 | at java.net.URLClassLoader.findClass(Unknown Source)
10:57:43 AM web.1 | at java.lang.ClassLoader.loadClass(Unknown Source)
10:57:43 AM web.1 | at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
10:57:43 AM web.1 | at java.lang.ClassLoader.loadClass(Unknown Source)
J'ai mon firebase_key.json dans la racine de l'application.
Quelle en est la cause ?