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'apply plugin: 'com.google.gms.google-services'
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
留言
張貼留言