Skip to content

Instantly share code, notes, and snippets.

@arif-pandu
Created December 16, 2022 09:58
Show Gist options
  • Save arif-pandu/8528b91a0987df6a49d59028ca8bb46a to your computer and use it in GitHub Desktop.
Save arif-pandu/8528b91a0987df6a49d59028ca8bb46a to your computer and use it in GitHub Desktop.
How To Add Firebase Analytics and Crashlytics in Flutter
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.google.firebase.crashlytics'
android {
compileSdkVersion 31
...
defaultConfig {
applicationId "com.dicoding.ditonton"
minSdkVersion 19
targetSdkVersion 30
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
multiDexEnabled true
}
buildTypes {
release {
signingConfig signingConfigs.debug
}
}
}
...
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation platform('com.google.firebase:firebase-bom:31.1.1')
implementation 'com.google.firebase:firebase-analytics'
implementation 'com.google.firebase:firebase-crashlytics'
}
buildscript {
...
repositories {
google()
jcenter()
mavenCentral()
}
dependencies {
...
classpath 'com.google.gms:google-services:4.3.13'
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.9.2'
}
}
allprojects {
repositories {
google()
jcenter()
mavenCentral()
}
}
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
FlutterError.onError = FirebaseCrashlytics.instance.recordFlutterFatalError;
runApp(MyApp());
}
...
firebase_core: latest_version
firebase_analytics: latest_version
firebase_crashlytics: latest_version
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment