Skip to content

Commit

Permalink
ML-51 Integrate Crashlytics (#52)
Browse files Browse the repository at this point in the history
* added crashlytics

* added firebase_options to CD

* Version bump

* added firebase_options to CI

* timeout
  • Loading branch information
vodemn committed May 3, 2023
1 parent 6944da2 commit 6232ad5
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 21 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/cd_dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/cd_prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 9 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
4 changes: 1 addition & 3 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
include: package:flutter_lints/flutter.yaml
analyzer:
exclude: [lib/main_prod.dart]
include: package:flutter_lints/flutter.yaml
1 change: 1 addition & 0 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
1 change: 1 addition & 0 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
Expand Down
14 changes: 14 additions & 0 deletions lib/firebase.dart
Original file line number Diff line number Diff line change
@@ -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;
};
}
3 changes: 3 additions & 0 deletions lib/main_prod.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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()));
}
4 changes: 3 additions & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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
Expand Down

0 comments on commit 6232ad5

Please sign in to comment.