I configured my flutter project with the Firebase CLI,
I did it by following the necessary steps in flutter fire docs. I also did the manual installation for the emulator but my problem was not solved
Flutterfire documents : https://firebase.flutter.dev/docs/overview
My problem is this:
(V) Firebase plugins work when I compile it into Flutter WEB
(X) But it does not work in the emulator.
* I've done the SHA-KEY additions to the console firebase
* I've updated the google-services.json file.
* I also updated two build gradle files
I get the following errors when starting the application
>> Note: Some input files use or override a deprecated API.
>> Note: Recompile with -Xlint:deprecation for details.
i also run the following console codes for this error
flutter pub upgrade
flutter clean
flutter run
Video Link
sorry for the watermark in the video :)
if you see my problem as a video I hope i can be fully understood
main.dart file
import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'firebase_options.dart';
/*
...
*/
void main() async {
WidgetsFlutterBinding.ensureInitialized();
SystemChrome.setSystemUIOverlayStyle(const SystemUiOverlayStyle(
statusBarColor: Colors.transparent, //Set status bar color
));
await Firebase.initializeApp(
options: DefaultFirebaseOptions.currentPlatform,
);
bool isIntroPass = await HelperFunctions.getAppIntroduction();
runApp(KampApp(isPassIntro: isIntroPass));
}
class KampApp extends StatefulWidget {
final bool isPassIntro;
const KampApp({super.key, this.isPassIntro = true});
@override
State<KampApp> createState() => _KampAppState();
}
class _KampAppState extends State<KampApp> {
bool isLogged = false;
@override
void initState() {
super.initState();
getUserLoggedStatus();
}
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
title: Constants.appTitle,
themeMode: ThemeMode.system,
theme: MyThemes.lightTheme(context),
darkTheme: MyThemes.darkTheme(context),
home: widget.isPassIntro
? isLogged
? const HomePage()
: const LoginPage()
: const IntroPage(),
onGenerateRoute: RouteGenarator.routeGenarator,
);
}
}
android/build.gradle
buildscript {
ext.kotlin_version = '1.6.10'
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.1.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.3.13'//google services
}
}
allprojects {
repositories {
google()
mavenCentral()
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
task clean(type: Delete) {
delete rootProject.buildDir
}
android/app/build.gradle
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}
def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
}
def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.0'
}
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'com.google.gms.google-services'//google services
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
compileSdkVersion flutter.compileSdkVersion
ndkVersion flutter.ndkVersion
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
sourceSets {
main.java.srcDirs = 'src/main/kotlin'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.mypackagename"
// You can update the following values to match your application needs.
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration.
minSdkVersion 19
targetSdkVersion flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
multiDexEnabled true
}
buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.debug
}
}
}
flutter {
source '../..'
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation platform('com.google.firebase:firebase-bom:30.4.1')//firebase bom
implementation 'com.android.support:multidex:1.0.3'//mulitdex
}
CodePudding user response:
try to add firebase to your project with the instruction from firebase console
CodePudding user response:
these are the warning messages you can ignore them, have you addded the firebase initializer in the main.dart file?
Note: Some input files use or override a deprecated API. Note: Recompile with -Xlint:deprecation for details.
Need to add this line in main.dart
await Firebase.initializeApp( options: DefaultFirebaseOptions.currentPlatform, );