I'm using crashytics from Fabric.io in my app.
Here's how I have initialised it in my MainActivity.java
at the very last of onCreate()
method:
Fabric.with(this, new Crashlytics());
Here's build.gradle (Project: abc)
file:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
mavenCentral()
maven { url 'https://maven.fabric.io/public'}
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
classpath 'com.google.gms:google-services:3.0.0'
classpath 'io.fabric.tools:gradle:1.+'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
maven { url "https://dl.bintray.com/hani-momanii/maven"}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Here's build.gradle (Module: app)
file:
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
android {
compileSdkVersion 25
buildToolsVersion "25.0.0"
defaultConfig {
applicationId "com.xxx.abc"
minSdkVersion 16
targetSdkVersion 25
versionCode 1
versionName "1.0"
multiDexEnabled true
vectorDrawables.useSupportLibrary = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
repositories {
mavenCentral()
maven {
url "https://jitpack.io"
}
maven { url 'https://maven.fabric.io/public' }
}
dexOptions {
javaMaxHeapSize "4g"
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile('com.crashlytics.sdk.android:crashlytics:2.6.6@aar') {
transitive = true;
}
}
apply plugin: 'com.google.gms.google-services'
and
<meta-data
android:name="io.fabric.ApiKey"
android:value="xxxxxxxxxxxxxxxxxxxxxxxxxxx"
/>
is defined in the AndroidManifest.xml
between <application>
tags.
The problem is that I'm unable to get the crash reports whenever the app crashes while not connected to Android Studio though I get the reports when the app crashes while connected to it.
Why is this happening and how can I get the crash reports each and every time the app crashes whether connected to Android Studio or not?
Remove from Activity
and put inside Application class
public class MyApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
Fabric.with(this, new Crashlytics());
}
Don't forget to add name in Application tag of manifest.xml
<application
...
android:name=".MyApplication"
...
</application>