Android studio Connect to Firebase

 


Make sure to call FirebaseApp.initializeApp(Context) first. Default FirebaseApp is not initialized in this process com.example.login


Default FirebaseApp is not initialized in this process com.example.taxibeta1. Make sure to call FirebaseApp.initializeApp(Context) first.


Setting:


1. under build.gradle

classpath 'com.google.gms:google-services:4.2.0'




2. under build.gradle
apply plugin: 'com.google.gms.google-services'




and Add
implementation 'com.google.firebase:firebase-storage:19.2.0'
implementation 'com.google.firebase:firebase-analytics:17.5.0'
implementation 'com.google.firebase:firebase-auth:19.4.0'
implementation 'com.google.firebase:firebase-firestore:21.7.0'

3. Error occurs Add  google-services.json

Check the error and see the path, the json file is downloaded in Firebase





4. Test code, you are able to connect Firebase

private void uploadImage(Bitmap bitmap) {

FirebaseApp.initializeApp(this);
FirebaseStorage storage = FirebaseStorage.getInstance("gs://savetostorage-451aa.appspot.com");
StorageReference storageRef = storage.getReference("a.jpg");
storageRef.getPath();
storageRef.getName();

}



Reference:

https://stackoverflow.com/questions/55709341/make-sure-to-call-firebaseapp-initializeappcontext-first-default-firebaseapp


Upload file 

https://firebase.google.com/docs/storage/android/upload-files


留言

這個網誌中的熱門文章

香港袐密行動

要老是忘記, 我更記不起