amoriai/FIREBASE_SETUP_FINAL.md

123 lines
3.1 KiB
Markdown

# 🔥 Firebase Setup - Final Steps
## ✅ **Yang Sudah Selesai:**
- Firebase project configured: `sembarang-826ce`
- FlutterFire CLI setup
- Firebase initialization code updated
- Gemini API key: `AIzaSyBOgaUAFoVOooo8WplbBanntZdqlC7u1bE`
## 🚀 **Langkah Terakhir untuk Google Sign-in:**
### **1. Enable Google Authentication**
1. **Buka Firebase Console:**
- https://cons ole.firebase.google.com/project/sembarang-826ce
2. **Enable Authentication:**
- Klik **Authentication****Get started**
- Klik **Sign-in method**
- Klik **Google****Enable**
- **Project support email**: Pilih email Anda
- Klik **Save**
### **2. Get Web Client ID**
1. **Di Firebase Console:**
- Klik **Project Settings** (gear icon)
- Tab **General**
- Scroll ke **Your apps**
- Klik **Web app** (bukan Android app)
- Copy **Web client ID** (format: `960796982375-xxxxxxxxxxxxxxxxxxxxxxxx.apps.googleusercontent.com`)
### **3. Set Environment Variables**
**Option A: Run Script (Easy)**
```bash
# Edit set_env.bat dan update Web Client ID, lalu run:
set_env.bat
```
**Option B: Manual PowerShell**
```powershell
# Set Gemini API Key
$env:GEMINI_API_KEY="AIzaSyBOgaUAFoVOooo8WplbBanntZdqlC7u1bE"
# Set Google Client ID (replace dengan Web Client ID yang sebenarnya)
$env:GOOGLE_SIGN_IN_CLIENT_ID="960796982375-your_actual_web_client_id.apps.googleusercontent.com"
```
### **4. Test Application**
```bash
flutter run
```
## 🔍 **Expected Results:**
### **Debug Console Output:**
```
✅ Firebase initialized
✅ Gemini service initialized
=== App Configuration ===
API URL: https://dev-api.muningkofie.com
Debug Mode: true
Gemini API Key: Set
Google Sign-In: Set
Config Valid: true
========================
```
### **App Behavior:**
- ✅ No Firebase initialization errors
- ✅ Google Sign-in button works
- ✅ Can authenticate with Google account
- ✅ User data saved to Firestore
## 🔧 **Troubleshooting:**
### **Error: "No Firebase App '[DEFAULT]' has been created"**
- Restart terminal after setting environment variables
- Make sure Firebase initialization runs before any Firebase calls
### **Google Sign-in Error**
- Verify Web Client ID is correct (not Android Client ID)
- Make sure Google authentication is enabled in Firebase Console
- Check SHA-1 fingerprint is added for Android (if testing on device)
### **API Key Errors**
- Verify Gemini API key is valid at https://makersuite.google.com/app/apikey
- Make sure environment variable is set correctly
## 📱 **Next Steps After Setup:**
1. **Test all features:**
- Google Sign-in ✅
- Camera OCR
- AI recommendations
- Data persistence
2. **Production setup:**
- Add release SHA-1 fingerprint
- Configure Firebase security rules
- Setup analytics
## 🎯 **Quick Commands:**
```bash
# Set environment variables
set_env.bat
# Run app
flutter run
# Check Firebase project
firebase projects:list
# Open Firebase Console
start https://console.firebase.google.com/project/sembarang-826ce
```
---
**🎉 Setelah langkah ini selesai, aplikasi Muning Menu Recommender akan fully functional dengan Firebase dan Gemini AI!**