Commit 9e273858 authored by Lucio Maciel's avatar Lucio Maciel

Initial Crashlytics support

parent ac8ea75a
apply plugin: 'com.android.application' apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
repositories {
maven { url 'https://maven.fabric.io/public' }
}
apply plugin: 'kotlin-android' apply plugin: 'kotlin-android'
apply plugin: 'me.tatarka.retrolambda' apply plugin: 'me.tatarka.retrolambda'
apply plugin: 'com.jakewharton.hugo' apply plugin: 'com.jakewharton.hugo'
...@@ -9,6 +15,7 @@ buildscript { ...@@ -9,6 +15,7 @@ buildscript {
repositories { repositories {
jcenter() jcenter()
mavenCentral() mavenCentral()
maven { url 'https://maven.fabric.io/public' }
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:2.3.3' classpath 'com.android.tools.build:gradle:2.3.3'
...@@ -22,6 +29,7 @@ buildscript { ...@@ -22,6 +29,7 @@ buildscript {
classpath 'com.jakewharton.hugo:hugo-plugin:1.2.1' classpath 'com.jakewharton.hugo:hugo-plugin:1.2.1'
classpath 'com.google.gms:google-services:3.0.0' classpath 'com.google.gms:google-services:3.0.0'
classpath 'com.github.triplet.gradle:play-publisher:1.1.5' classpath 'com.github.triplet.gradle:play-publisher:1.1.5'
classpath 'io.fabric.tools:gradle:1.+'
} }
// Exclude the version that the android plugin depends on. // Exclude the version that the android plugin depends on.
...@@ -134,6 +142,9 @@ dependencies { ...@@ -134,6 +142,9 @@ dependencies {
compile "com.github.hotchemi:permissionsdispatcher:$permissionsdispatcherVersion" compile "com.github.hotchemi:permissionsdispatcher:$permissionsdispatcherVersion"
annotationProcessor "com.github.hotchemi:permissionsdispatcher-processor:$permissionsdispatcherVersion" annotationProcessor "com.github.hotchemi:permissionsdispatcher-processor:$permissionsdispatcherVersion"
compile('com.crashlytics.sdk.android:crashlytics:2.6.8@aar') {
transitive = true;
}
} }
apply plugin: 'com.google.gms.google-services' apply plugin: 'com.google.gms.google-services'
...@@ -69,5 +69,8 @@ ...@@ -69,5 +69,8 @@
<action android:name="com.google.android.gms.iid.InstanceID"/> <action android:name="com.google.android.gms.iid.InstanceID"/>
</intent-filter> </intent-filter>
</service> </service>
<meta-data
android:name="io.fabric.ApiKey"
android:value="12ac6e94f850aaffcdff52001af77ca415d06a43" />
</application> </application>
</manifest> </manifest>
\ No newline at end of file
...@@ -2,9 +2,11 @@ package chat.rocket.android; ...@@ -2,9 +2,11 @@ package chat.rocket.android;
import android.os.StrictMode; import android.os.StrictMode;
import android.support.multidex.MultiDexApplication; import android.support.multidex.MultiDexApplication;
import com.crashlytics.android.Crashlytics;
import com.facebook.stetho.Stetho; import com.facebook.stetho.Stetho;
import com.uphyca.stetho_realm.RealmInspectorModulesProvider; import com.uphyca.stetho_realm.RealmInspectorModulesProvider;
import io.fabric.sdk.android.Fabric;
import java.util.List; import java.util.List;
import chat.rocket.android.helper.OkHttpHelper; import chat.rocket.android.helper.OkHttpHelper;
import chat.rocket.persistence.realm.RealmStore; import chat.rocket.persistence.realm.RealmStore;
...@@ -24,6 +26,7 @@ public class RocketChatApplication extends MultiDexApplication { ...@@ -24,6 +26,7 @@ public class RocketChatApplication extends MultiDexApplication {
} }
super.onCreate(); super.onCreate();
Fabric.with(this, new Crashlytics());
RocketChatPersistenceRealm.init(this); RocketChatPersistenceRealm.init(this);
......
package chat.rocket.android.helper; package chat.rocket.android.helper;
import com.crashlytics.android.Crashlytics;
import com.google.firebase.crash.FirebaseCrash; import com.google.firebase.crash.FirebaseCrash;
import bolts.Continuation; import bolts.Continuation;
...@@ -11,14 +12,16 @@ import chat.rocket.android.log.RCLog; ...@@ -11,14 +12,16 @@ import chat.rocket.android.log.RCLog;
* Bolts-Task continuation for just logging if error occurred. * Bolts-Task continuation for just logging if error occurred.
*/ */
public class LogIfError implements Continuation { public class LogIfError implements Continuation {
@Override @Override
public Object then(Task task) throws Exception { public Object then(Task task) throws Exception {
if (task.isFaulted()) { if (task.isFaulted()) {
if (BuildConfig.DEBUG) { if (BuildConfig.DEBUG) {
RCLog.w(task.getError()); RCLog.w(task.getError());
} }
FirebaseCrash.report(task.getError());
FirebaseCrash.report(task.getError());
Crashlytics.logException(task.getError());
}
return task;
} }
return task;
}
} }
package chat.rocket.android.helper; package chat.rocket.android.helper;
import com.crashlytics.android.Crashlytics;
import com.google.firebase.crash.FirebaseCrash; import com.google.firebase.crash.FirebaseCrash;
public class Logger { public class Logger {
public static void report(Throwable throwable) { public static void report(Throwable throwable) {
FirebaseCrash.report(throwable); FirebaseCrash.report(throwable);
} Crashlytics.logException(throwable);
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment