When I run the app in debug mode, everything works fine, but when I use any type of release build, including flutter run -d chrome --release I get the error No Firebase App '[DEFAULT]' has been created - call Firebase App.initializeApp() (app/no-app). The error comes from main.dart.js.
Index.html:
<script src="https://www.gstatic.com/firebasejs/8.6.1/firebase-app.js"></script>
<script src="https://www.gstatic.com/firebasejs/8.6.1/firebase-analytics.js"></script>
<!--<script src="https://www.gstatic.com/firebasejs/8.6.1/firebase-auth.js"></script>-->
<script src="https://www.gstatic.com/firebasejs/8.6.1/firebase-firestore.js"></script>
<script type="module">
const firebaseConfig = {
apiKey: "___",
authDomain: "___",
projectId: "___",
storageBucket: "___",
messagingSenderId: "___",
appId: "___",
measurementId: "____"
};
// Initialize Firebase
firebase.initializeApp(firebaseConfig);
firebase.analytics();
firebase.firestore();
</script>
main.dart:
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
runApp(ModularApp(
module: AppModule(),
));
}
I've been trying to figure out what could be the problem for a very long time now. It works perfectly on both Android and web debug, but gives this one error on web release.