From 6c4c4df6ab8830864fad3f3c47a7dbad301d98f5 Mon Sep 17 00:00:00 2001 From: Ezerous Date: Mon, 12 Dec 2016 16:03:23 +0200 Subject: [PATCH] Crash report implementation --- .gitignore | 5 +- app/build.gradle | 3 + app/src/debug/google-services.json | 73 +++++++++++++++++++ .../thmmy/mthmmy/session/SessionManager.java | 2 +- app/src/release/java/mthmmy.utils/Report.java | 41 +++++++---- build.gradle | 2 +- 6 files changed, 109 insertions(+), 17 deletions(-) create mode 100644 app/src/debug/google-services.json diff --git a/.gitignore b/.gitignore index 89443587..252008e0 100644 --- a/.gitignore +++ b/.gitignore @@ -44,4 +44,7 @@ captures/ .externalNativeBuild ### Android Patch ### -gen-external-apklibs \ No newline at end of file +gen-external-apklibs + +# Google Services (release build) +app/src/release/google-services.json \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle index 546db31d..3d8a44ad 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -32,6 +32,7 @@ dependencies { compile 'com.android.support:support-v4:25.0.1' compile 'com.android.support:cardview-v7:25.0.1' compile 'com.android.support:recyclerview-v7:25.0.1' + compile 'com.google.firebase:firebase-crash:10.0.1' compile 'com.squareup.okhttp3:okhttp:3.5.0' compile 'com.squareup.picasso:picasso:2.5.2' compile 'com.jakewharton.picasso:picasso2-okhttp3-downloader:1.1.0' @@ -42,3 +43,5 @@ dependencies { } compile 'com.mikepenz:fontawesome-typeface:4.7.0.0@aar' } + +apply plugin: 'com.google.gms.google-services' diff --git a/app/src/debug/google-services.json b/app/src/debug/google-services.json new file mode 100644 index 00000000..0234f060 --- /dev/null +++ b/app/src/debug/google-services.json @@ -0,0 +1,73 @@ +{ + "project_info": { + "project_number": "934432863001", + "firebase_url": "https://mthmmy-debug.firebaseio.com", + "project_id": "mthmmy-debug", + "storage_bucket": "mthmmy-debug.appspot.com" + }, + "client": [ + { + "client_info": { + "mobilesdk_app_id": "1:934432863001:android:a921e0b04ab1f00b", + "android_client_info": { + "package_name": "gr.thmmy.mtmmy" + } + }, + "oauth_client": [ + { + "client_id": "934432863001-d5oocs1vdi0pcepesi55a41p7enphfcv.apps.googleusercontent.com", + "client_type": 3 + } + ], + "api_key": [ + { + "current_key": "AIzaSyD4-gwVcb2Rc8zeT8l1v2Lg1DU0QgfGtk8" + } + ], + "services": { + "analytics_service": { + "status": 1 + }, + "appinvite_service": { + "status": 1, + "other_platform_oauth_client": [] + }, + "ads_service": { + "status": 2 + } + } + }, + { + "client_info": { + "mobilesdk_app_id": "1:934432863001:android:088be0537ff6b292", + "android_client_info": { + "package_name": "gr.thmmy.mthmmy" + } + }, + "oauth_client": [ + { + "client_id": "934432863001-d5oocs1vdi0pcepesi55a41p7enphfcv.apps.googleusercontent.com", + "client_type": 3 + } + ], + "api_key": [ + { + "current_key": "AIzaSyD4-gwVcb2Rc8zeT8l1v2Lg1DU0QgfGtk8" + } + ], + "services": { + "analytics_service": { + "status": 1 + }, + "appinvite_service": { + "status": 1, + "other_platform_oauth_client": [] + }, + "ads_service": { + "status": 2 + } + } + } + ], + "configuration_version": "1" +} \ No newline at end of file diff --git a/app/src/main/java/gr/thmmy/mthmmy/session/SessionManager.java b/app/src/main/java/gr/thmmy/mthmmy/session/SessionManager.java index 4b437903..92acba97 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/session/SessionManager.java +++ b/app/src/main/java/gr/thmmy/mthmmy/session/SessionManager.java @@ -162,7 +162,7 @@ public class SessionManager //Handle exception } catch (InterruptedIOException e){ - Report.i(TAG, "Login InterruptedIOException", e); //users cancels LoginTask + Report.i(TAG, "Login InterruptedIOException"); //users cancels LoginTask return CANCELLED; } catch (IOException e) { diff --git a/app/src/release/java/mthmmy.utils/Report.java b/app/src/release/java/mthmmy.utils/Report.java index 5825481f..7757f659 100644 --- a/app/src/release/java/mthmmy.utils/Report.java +++ b/app/src/release/java/mthmmy.utils/Report.java @@ -1,67 +1,80 @@ package mthmmy.utils; -import android.util.Log; +import com.google.firebase.crash.FirebaseCrash; -public class Report //TODO implement for release +public class Report { public static void v (String TAG, String message) { - Log.v(TAG,message); + log("V", TAG, message); } public static void v (String TAG, String message, Throwable tr) { - Log.v(TAG,message + ": " + tr.getMessage(),tr); + exception("V", TAG, message, tr); } public static void d (String TAG, String message) { - Log.d(TAG,message); + log("D", TAG, message); } public static void d (String TAG, String message, Throwable tr) { - Log.d(TAG,message + ": " + tr.getMessage(),tr); + exception("D", TAG, message, tr); } public static void i (String TAG, String message) { - Log.i(TAG,message); + log("I", TAG, message); } public static void i (String TAG, String message, Throwable tr) { - Log.i(TAG,message + ": " + tr.getMessage(),tr); + exception("I", TAG, message, tr); } public static void w (String TAG, String message) { - Log.w(TAG,message); + log("W", TAG, message); } public static void w (String TAG, String message, Throwable tr) { - Log.w(TAG,message + ": " + tr.getMessage(),tr); + exception("W", TAG, message, tr); } public static void e (String TAG, String message) { - Log.e(TAG,message); + log("E", TAG, message); } public static void e (String TAG, String message, Throwable tr) { - Log.e(TAG,message + ": " + tr.getMessage(),tr); + exception("E", TAG, message, tr); } public static void wtf (String TAG, String message) { - Log.wtf(TAG,message); + log("WTF", TAG, message); } public static void wtf (String TAG, String message, Throwable tr) { - Log.wtf(TAG,message + ": " + tr.getMessage(),tr); + exception("WTF", TAG, message, tr); } + + private static void log(String level, String TAG, String message) + { + FirebaseCrash.log(level + "/" + TAG + ": " + message); + } + + private static void exception(String level, String TAG, String message, Throwable tr) + { + FirebaseCrash.log(level + "/" + TAG + ": " + message + ": " + tr.getMessage()); + FirebaseCrash.report(tr); + } + + } \ No newline at end of file diff --git a/build.gradle b/build.gradle index b0aa0b0a..25e7e862 100644 --- a/build.gradle +++ b/build.gradle @@ -7,7 +7,7 @@ buildscript { } dependencies { classpath 'com.android.tools.build:gradle:2.2.3' - + classpath 'com.google.gms:google-services:3.0.0' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files }