ML-51 Integrate Crashlytics (#52)

* added crashlytics

* added firebase_options to CD

* Version bump

* added firebase_options to CI

* timeout
This commit is contained in:
Vadim 2023-05-03 12:45:10 +02:00 committed by GitHub
parent 6944da25fa
commit 6232ad555a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 46 additions and 21 deletions

View file

@ -59,13 +59,13 @@ jobs:
echo -n "$GOOGLE_SERVICES_JSON_ANDROID" | base64 --decode --output $GOOGLE_SERVICES_JSON_ANDROID_PATH
cp $GOOGLE_SERVICES_JSON_ANDROID_PATH ./android/app
# - name: Restore lib/firebase_options.dart
# env:
# KEYSTORE: ${{ secrets.FIREBASE_OPTIONS }}
# run: |
# FIREBASE_OPTIONS_PATH=$RUNNER_TEMP/firebase_options.dart
# echo -n "$FIREBASE_OPTIONS" | base64 --decode --output $FIREBASE_OPTIONS_PATH
# cp $FIREBASE_OPTIONS_PATH ./lib
- name: Restore firebase_options.dart
env:
FIREBASE_OPTIONS: ${{ secrets.FIREBASE_OPTIONS }}
run: |
FIREBASE_OPTIONS_PATH=$RUNNER_TEMP/firebase_options.dart
echo -n "$FIREBASE_OPTIONS" | base64 --decode --output $FIREBASE_OPTIONS_PATH
cp $FIREBASE_OPTIONS_PATH ./lib
- name: Install Flutter
uses: subosito/flutter-action@v2

View file

@ -50,13 +50,13 @@ jobs:
echo -n "$GOOGLE_SERVICES_JSON_ANDROID" | base64 --decode --output $GOOGLE_SERVICES_JSON_ANDROID_PATH
cp $GOOGLE_SERVICES_JSON_ANDROID_PATH ./android/app
# - name: Restore firebase_options.dart
# env:
# FIREBASE_OPTIONS: ${{ secrets.FIREBASE_OPTIONS }}
# run: |
# FIREBASE_OPTIONS_PATH=$RUNNER_TEMP/firebase_options.dart
# echo -n "$FIREBASE_OPTIONS" | base64 --decode --output $FIREBASE_OPTIONS_PATH
# cp $FIREBASE_OPTIONS_PATH ./lib
- name: Restore firebase_options.dart
env:
FIREBASE_OPTIONS: ${{ secrets.FIREBASE_OPTIONS }}
run: |
FIREBASE_OPTIONS_PATH=$RUNNER_TEMP/firebase_options.dart
echo -n "$FIREBASE_OPTIONS" | base64 --decode --output $FIREBASE_OPTIONS_PATH
cp $FIREBASE_OPTIONS_PATH ./lib
- name: Install Flutter
uses: subosito/flutter-action@v2

View file

@ -14,7 +14,7 @@ on:
jobs:
build:
runs-on: macos-11
timeout-minutes: 5
timeout-minutes: 10
steps:
- uses: shaunco/ssh-agent@git-repo-mapping
@ -41,7 +41,13 @@ jobs:
- name: Generate intl
run: flutter pub run intl_utils:generate
- name: Restore firebase_options.dart
env:
FIREBASE_OPTIONS: ${{ secrets.FIREBASE_OPTIONS }}
run: |
FIREBASE_OPTIONS_PATH=$RUNNER_TEMP/firebase_options.dart
echo -n "$FIREBASE_OPTIONS" | base64 --decode --output $FIREBASE_OPTIONS_PATH
cp $FIREBASE_OPTIONS_PATH ./lib
- name: Analyze project source
run: flutter analyze lib --fatal-infos
# - name: Run tests
# run: flutter test

View file

@ -1,3 +1 @@
include: package:flutter_lints/flutter.yaml
analyzer:
exclude: [lib/main_prod.dart]

View file

@ -29,6 +29,7 @@ if (keystorePropertiesFile.exists()) {
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.google.firebase.crashlytics'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

View file

@ -8,6 +8,7 @@ buildscript {
dependencies {
classpath 'com.android.tools.build:gradle:7.1.2'
classpath 'com.google.gms:google-services:4.3.10'
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.8.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}

14
lib/firebase.dart Normal file
View file

@ -0,0 +1,14 @@
import 'package:firebase_core/firebase_core.dart';
import 'package:firebase_crashlytics/firebase_crashlytics.dart';
import 'package:flutter/foundation.dart';
import 'firebase_options.dart';
Future<void> initializeFirebase() async {
await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform);
FlutterError.onError = FirebaseCrashlytics.instance.recordFlutterFatalError;
PlatformDispatcher.instance.onError = (error, stack) {
FirebaseCrashlytics.instance.recordError(error, stack, fatal: true);
return true;
};
}

View file

@ -2,8 +2,11 @@ import 'package:flutter/material.dart';
import 'package:lightmeter/environment.dart';
import 'application.dart';
import 'firebase.dart';
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
await initializeFirebase();
runApp(const Application(Environment.prod()));
}

View file

@ -1,7 +1,7 @@
name: lightmeter
description: A new Flutter project.
publish_to: "none"
version: 0.9.1+16
version: 0.9.2+17
environment:
sdk: ">=2.18.0 <3.0.0"
@ -11,6 +11,8 @@ dependencies:
camera: 0.10.0+4
exif: 3.1.2
dynamic_color: 1.5.4
firebase_core: 2.10.0
firebase_crashlytics: 3.1.2
flutter:
sdk: flutter
flutter_bloc: 8.1.1