50

I have this mainActivity

public class MainActivity extends RoboFragmentActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Crashlytics.start(this);
        //setContentView(R.layout.activity_main);

        Intent intent = new Intent(this, MainActivity_with_Fragment.class);
        startActivity(intent);
        finish();
    }
}

this is my gradle.build

buildscript {
    repositories {
        jcenter()
        maven { url 'http://download.crashlytics.com/maven' }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.14.2'
        classpath 'com.crashlytics.tools.gradle:crashlytics-gradle:1.+'
    }
}
apply plugin: 'com.android.application'
apply plugin: 'crashlytics'

repositories {
    jcenter()
    maven { url 'http://download.crashlytics.com/maven' }
}

android {
    compileSdkVersion 19
    buildToolsVersion "19.1.0"

    defaultConfig {
        applicationId "com.example.stopcall.app"
        minSdkVersion 14
        targetSdkVersion 19
        versionCode 1
        versionName "1.0"
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
    }
    buildTypes {
        release {
            runProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    lintOptions {
        abortOnError false
    }
}


dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:support-v4:21.0.3'
    compile 'org.roboguice:roboguice:3.+'
    provided 'org.roboguice:roboblender:3.+'
    compile 'com.crashlytics.android:crashlytics:1.+'
}

When I run project build I get this compilation error:

Error:Gradle: Execution failed for task ':app:crashlyticsCleanupResourcesDebug'.
> Crashlytics Developer Tools error.

how can I fix this?

Sufian
  • 6,405
  • 16
  • 66
  • 120
Elad Benda
  • 35,076
  • 87
  • 265
  • 471
  • This doesn't seem like enough info to debug the problem. Can you try compiling from the command line with verbose output (gradle -info compileDebugSources). Post the error messages from that output. – AndroidGuy Feb 01 '15 at 18:23
  • 2
    Have you added your API key to the app manifest? I had this same error and that was my issue. – Nathan Schwermann Mar 05 '15 at 23:23
  • I also got the issue and resolved it by putting string directly in meta tag without defining the api key into string resources. e.g. Replace **** to **** – Hassan Jamil Dec 03 '16 at 15:01
  • I have a solution, fix of this problem: Please get my answer from this link https://stackoverflow.com/a/40949152/3819836 – Hassan Jamil Oct 02 '17 at 10:54
  • I fixed this issue by following [Hassan Jamil's answer](http://stackoverflow.com/a/40949152/3819836). Thank you so much. – Rohit Gupta Dec 23 '17 at 10:38

12 Answers12

67

You need to add your API Key to the Android Manifest:

<application>
    <meta-data
        android:name="com.crashlytics.ApiKey"
        android:value="your key here" />
</application>
Bill Mote
  • 12,644
  • 7
  • 58
  • 82
  • 2
    i only want to use fabric for twitter login. Why should i use crashlytics. Still i got same issue. Can you please give solution to that? – Shreyash Mahajan Jun 22 '15 at 05:36
  • This is automatically added when using the plugin. And I am still receiving this error. I am not sure that this is the solution. – portfoliobuilder Sep 25 '15 at 22:48
  • I was assigning string resource (because of different live and debug keys) to `value`. It appears that it doesn't work. Sad. – Sufian Jul 14 '16 at 13:24
36

This method solved my problem:

Remove or Comment this line (build.gradle):

  // apply plugin: 'io.fabric'

or if you have an ApiKey, define fabric ApiKey (AndroidManifest.xml)

    <meta-data
        android:name="io.fabric.ApiKey"
        android:value="yourApiKey012356465654" />
Fthr
  • 769
  • 9
  • 10
25

If you only want to compose a tweet with the SDK you can remove the line

apply plugin: 'io.fabric'

And the gradle build will work correctly

Khriz
  • 5,888
  • 6
  • 34
  • 39
18

I also got the issue and resolved it by putting string directly in meta tag without defining the api key into string resources.

e.g. Replace

<meta-data
        android:name="io.fabric.ApiKey"
        android:value="@string/string_res_name_of_your_api_key" />

to

<meta-data
        android:name="io.fabric.ApiKey"
        android:value="your_api_key_string" />
Hassan Jamil
  • 951
  • 1
  • 13
  • 33
  • Android Studio (2.3 Canary 2, Build #AI-162.3508619, built on November 18, 2016) error here I think! This solution worked for me – droppin_science Dec 15 '16 at 10:52
  • I still ran into this issue with Android Studio 2.3.3. This solution worked. The issue didn't occur as long as my project consisted of one module. It occurred when I added the crashlytics dependency in a library project and applied the plugin in the app module. – Peter F Aug 24 '17 at 08:53
  • The issue resolved in our case with this answer. I did'nt understand though why ? – Debjit Jan 31 '18 at 13:41
8

When you follow the steps for adding an application in your Crashlytics dashboard, they have mentioned a step to add the api key. In my case I was getting the same error when I would try to fetch the key from the strings.xml file. The problem was that crashlytics plugin uses a runtime api key insertion method and hence the build fails as it is not able to get the key from the strings file.

I tried below step:

  1. Add a manifest placeholder in your build.gradle's defaultConfig:
    defaultConfig {
    manifestPlaceholders = [ api_key_crashlytics:"xxxx__your_api_key"]}
  1. In your AndroidManifest.xml add below code inside your application tag:
<meta-data
      android:name="io.fabric.ApiKey"
      android:value="${api_key_crashlytics}" />

This worked for me.

Manfred Radlwimmer
  • 13,257
  • 13
  • 53
  • 62
Sanket Mendon
  • 403
  • 5
  • 11
4

Please make sure you added

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

at the end of your build.gradle file.

stefan222
  • 669
  • 1
  • 11
  • 30
3

Open the Fabric Plugin which is already installed and update the Crashlytics, your problem gets solved

mixel
  • 25,177
  • 13
  • 126
  • 165
sonal balekai
  • 395
  • 4
  • 10
1

I faced with this issue for sometimes, although I already had api key in manifest. Then I try assemble release apk before try to assemble to upload to Fabric. So let execute:

$ ./gradlew assembleRelease

then

$ ./gradlew assembleRelease crashlyticsUploadDistributionRelease

and it works well.

Khai Nguyen
  • 3,065
  • 1
  • 31
  • 24
1

If you use distribution with Gradle you may have checked some properties like

ext.betaDistributionReleaseNotesFilePath=”path/to/release_notes.txt”

In our case we didn't have this file and the task crashed. To see the problem, go to Gradle console and check logs:

enter image description here

Gaket
  • 6,533
  • 2
  • 37
  • 67
0

I tried all of your solution suggests under that question and others. But all of them did not solve my problem. I solved my problem. My solution may solve your problem. I created empty res folder under main folder. project->src->main->res

Screenshot

mixel
  • 25,177
  • 13
  • 126
  • 165
elifekiz
  • 1,456
  • 13
  • 26
0

Most likely the ApiKey is not correct just check it out. Worked for me.

Goodlife
  • 3,822
  • 2
  • 24
  • 23
0

Your key may have been entered on the wrong Android Manifest

 <meta-data
    android:name="io.fabric.ApiKey"
    android:value="yourApiKey" />          //You must have 40 words

You can get the code after registering and entering the project

https://fabric.io/home

younes
  • 742
  • 7
  • 8