Crashlytics Fabric : Failed to execute task
Asked Answered
S

12

36

I've been having an issue and I don't know how to fix it.

My project use crashlytics, but it's always crash and not sent report. I have a TimeoutException:

08-25 03:04:31.876    2856-2856/connectivit.app E/Fabric﹕ Failed to execute task.
java.util.concurrent.TimeoutException
        at java.util.concurrent.FutureTask.get(FutureTask.java:176)
        at com.crashlytics.android.core.CrashlyticsExecutorServiceWrapper.executeSyncLoggingException(CrashlyticsExecutorServiceWrapper.java:44)
        at com.crashlytics.android.core.CrashlyticsUncaughtExceptionHandler.uncaughtException(CrashlyticsUncaughtExceptionHandler.java:275)
        at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:693)
        at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:690)
--------- beginning of crash
08-25 03:04:31.876    2856-2856/connectivit.app E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: connectivit.app, PID: 2856
java.lang.RuntimeException: Unable to start activity ComponentInfo{connectivit.app/connectivit.app.Activity.Main.MainActivity}: java.lang.RuntimeException: This is a crash
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2298)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
        at android.app.ActivityThread.access$800(ActivityThread.java:144)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:135)
        at android.app.ActivityThread.main(ActivityThread.java:5221)
        at java.lang.reflect.Method.invoke(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:372)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
 Caused by: java.lang.RuntimeException: This is a crash
        at connectivit.app.Activity.Main.MainActivity.initTabs(MainActivity.java:117)
        at connectivit.app.Activity.Main.MainActivity.onCreate(MainActivity.java:57)
        at android.app.Activity.performCreate(Activity.java:5933)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2251)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
        at android.app.ActivityThread.access$800(ActivityThread.java:144)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:135)
        at android.app.ActivityThread.main(ActivityThread.java:5221)
        at java.lang.reflect.Method.invoke(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:372)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)

EDIT

My build.gradle file :

buildscript {
    repositories {
        maven { url 'https://maven.fabric.io/public' }
    }

    dependencies {
        classpath 'io.fabric.tools:gradle:1.+'
    }
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'

repositories {
    maven { url "https://jitpack.io" }
    maven { url 'https://maven.fabric.io/public' }
}

android {
    signingConfigs {
        release {
            keyAlias 'android.keystore'
            storeFile file('/Users/jordan/android.keystore.jks')
            storePassword ""
            keyPassword ""
        }
        config {
            keyAlias 'androiddebugkey'
            keyPassword 'android'
            storeFile file('/Users/jordan/.android/debug.keystore')
            storePassword 'android'
        }
    }
    compileSdkVersion 23
    buildToolsVersion '23'
    defaultConfig {
        applicationId “com.test"
        minSdkVersion 14
        targetSdkVersion 23
        versionCode 12
        versionName '1'

        // Enabling multidex support.
        multiDexEnabled true
    }

    buildTypes {
        debug {
            versionNameSuffix "-DEBUG"
        }
        release {
            minifyEnabled true
            zipAlignEnabled true

            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            signingConfig signingConfigs.release
        }
    }
    packagingOptions {
        exclude 'META-INF/ASL2.0'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/NOTICE'
    }
    lintOptions {
        // set to true to turn off analysis progress reporting by lint
        quiet false
        // if true, stop the gradle build if errors are found
        abortOnError false
        // if true, only report errors
        ignoreWarnings true
    }
    productFlavors {
    }
}

dependencies {
    //--- Android
    compile 'com.android.support:design:23.0.0'
    compile 'com.android.support:appcompat-v7:23.0.0'
    compile 'com.android.support:multidex:1.0.0'

    //--- Fabric
    compile('com.crashlytics.sdk.android:crashlytics:2.4.0@aar') {
        transitive = true;
    }
}

Crashlytics initialization :

public class MyApplication extends MultiDexApplication {

 @Override
public void onCreate() {
    super.onCreate();

    Fabric.with(this, new Crashlytics());

    if (!BuildConfig.DEBUG) {
        Log.d("Ez", "Release mode. Crashlytics enable");
        //Fabric.with(this, new Crashlytics());
    } else {
        Log.d("Ez", "Debug mode. Crashlytics disable");
    }

    throw new RuntimeException("This is a crash");
    }
}
Sneck answered 25/8, 2015 at 7:11 Comment(4)
post your build.gradle and your Crashlitycs initializiation.Shotwell
You can find my build.gradle and my crashlitycs initialization in my previous postSneck
Have you tried throwing the runtime exception at a different time in the lifecycle? for example onResume in your first ActivityOpuntia
Yes I've tried OnCreate, OnResume, OnPause in my first Activity.Sneck
L
8

I fixed the TimeoutException by adding the following to my build.gradle

ext.enableCrashlytics = true

Or if you have several extensions already:

ext {
    ...
    enableCrashlytics = true
}

You can put it in your application's build.gradle.

Living answered 12/9, 2017 at 7:5 Comment(5)
where should I add them?Pagan
which build.gradle?Hulen
Putting it into the app's build.gradle fixed it for meObla
This did not resolve the issue in the Coinverse app. Here is the open-source code and a related StackOverflow post.Illconditioned
For KTS build.gradle - ext.set("enableCrashlytics", true)Sorbitol
B
8

This issue drove me crazy still in 2019, but I think I finally figured out, what did the exception cause.

I followed all the setup instructions given in the official firebase documentation, but when I tested my solution I didn't get any report on Firebase Crashlytics admin, because of the TimeoutException.

The reason was in my case, that I triggered the Exception in my main activity's onCreate() or onResume() methods. When I let my app at the first start just run without exception, then later I started to get the reports without any error, so I think it's important, that at the first start the app shouldn't throw any exception in the hook methods.

Hope my experience helped.

Beefy answered 4/9, 2019 at 21:40 Comment(0)
I
4

I got this issue as well. I solved it simply by doing Android Studio -> File -> Invalidate Caches / Restart -> Invalidate and restart

Imbricate answered 29/8, 2018 at 14:13 Comment(0)
S
1

Okay. Right after apply plugin section of your build.gradle put the ext solution

apply plugin: 'io.fabric'
apply plugin: 'com.google.gms.google-services'

ext {
    enableCrashlytics = true
}

android { }

!Then do Invalidate cache and restart. Also make sure you have implementation 'com.crashlytics.sdk.android:crashlytics:2.10.1'

Seftton answered 24/1, 2020 at 9:22 Comment(1)
This seems to be a duplicate answer within this post as this solution is covered here.Illconditioned
M
1

My solution is next:

  1. Remove all old Fabric related code
  2. Migrate fully app to Firebase. I use link for that
  3. My observation shows Crashlytic sends report next time app is launched and in case app crashes every time in Application::onCreate method you probably won't see any reporting in Firebase console.

How I test that:

  1. Thrown test exception in Application::onCreate method
  2. Commented that throwing and launch app again
  3. Approximately in a minute I saw crash in Firebase console.

Hope it also helps you!

Meteoritics answered 4/3, 2020 at 15:11 Comment(0)
A
0

For anyone still struggling with this, I solved it by installing android studio fabric plugin directly via Settings->Plugins android studio and let the plugin edit my code in gradle. You can see it done here : https://www.youtube.com/watch?v=Qvqr6vGzxIs

Archipenko answered 15/6, 2017 at 11:26 Comment(0)
E
0

Check Your AndroidManifest.xml file, it contains duplicate container or written more than two times that's it.

Because, I had faced this problem while I accidentally wrote the same container twice.

Eristic answered 27/9, 2018 at 10:5 Comment(0)
B
0

Same thing here, you follow the google docs and it just doesn't work. 5 years ago Crashlytics used to be extremely solid. Sad to see this.

Bondy answered 2/10, 2019 at 0:14 Comment(0)
W
0

In my case, I had some entries in AndroidManifest.xml that were not valid anymore. Java runtime couldn't find them, which caused the crash.

To be more precise, I was using a Facebook plugin that I removed but left some config entries in AndroiManifest.xml. After I removed them this error disappeared.

In your case, it could be something else in the AndroidManifest.

This is one of the possible causes. Each App is different.

Waves answered 29/4, 2020 at 21:2 Comment(0)
N
-4

According to Crashlytics support guide :

Make sure our SDK line is after all other 3rd-party SDKs

So try to set Fabric.with(this, new Crashlytics()); after all of your other sdk related initialization if any. If no other sdk initialization there then try to set it after your BuildConfig initialization.

public class MyApplication extends MultiDexApplication {

@Override
public void onCreate() {
   super.onCreate();  

    if (!BuildConfig.DEBUG) {
        Log.d("Ez", "Release mode. Crashlytics enable");
       //Fabric.with(this, new Crashlytics());
    } else {
        Log.d("Ez", "Debug mode. Crashlytics disable");
    }
   Fabric.with(this, new Crashlytics());

   throw new RuntimeException("This is a crash");
  }
}
Necessitous answered 4/12, 2015 at 8:38 Comment(0)
A
-4

Maybe you've another library that cause this error. Try to remove it,

for example you can try

maven { url "https://jitpack.io" }
Antelope answered 18/11, 2016 at 12:11 Comment(0)
S
-4

Cause the app may crash before Fabric can connect to its service. Solution: just remove your throw Exception code and perform a fresh install.

Scorecard answered 30/8, 2018 at 10:52 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.