3

I'm trying to install Crashlytics trough Fabric into my Android Studio Project I'm running into the following error:

Gradle tasks [:App:generateDebugSources, :App:generateDebugAndroidTestSources, :Customer:generateDebugSources, :Customer:generateDebugAndroidTestSources, :PDFViewCtrlTools:generateDebugSources, :PDFViewCtrlTools:generateDebugAndroidTestSources]
Crashlytics was applied to an android-library project. 
Android-library support is currently an incubating feature. 
Contact support@fabric.io with any issues.
Error:A problem occurred configuring project ':Customer'.
> Could not resolve all dependencies for configuration ':Customer:_debugCompile'.
  > Could not find com.crashlytics.sdk.android:crashlytics:2.2.1.
    Searched in the following locations:
       https://jcenter.bintray.com/com/crashlytics/sdk/android/crashlytics/2.2.1/crashlytics-2.2.1.pom
       https://jcenter.bintray.com/com/crashlytics/sdk/android/crashlytics/2.2.1/crashlytics-2.2.1.jar
       file:/Users/mes/Documents/Eclipse/sdk/extras/android/m2repository/com/crashlytics/sdk/android/crashlytics/2.2.1/crashlytics-2.2.1.pom
       file:/Users/mes/Documents/Eclipse/sdk/extras/android/m2repository/com/crashlytics/sdk/android/crashlytics/2.2.1/crashlytics-2.2.1.jar
       file:/Users/mes/Documents/Eclipse/sdk/extras/google/m2repository/com/crashlytics/sdk/android/crashlytics/2.2.1/crashlytics-2.2.1.pom
       file:/Users/mes/Documents/Eclipse/sdk/extras/google/m2repository/com/crashlytics/sdk/android/crashlytics/2.2.1/crashlytics-2.2.1.jar
       Required by:
       project:Customer:unspecified > project:App:unspecified
    Information:BUILD FAILED

This is my build.gradle:

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

    dependencies {
        classpath 'io.fabric.tools:gradle:1.+'
    }
}

apply plugin: 'com.android.library'
apply plugin: 'io.fabric'


repositories {
    mavenCentral()
    maven { url 'https://maven.fabric.io/public' }
}

dependencies {
    compile fileTree(dir: 'libs', include: '*.jar')
    compile 'com.google.android.gms:play-services:6.1.71'
    compile 'com.android.support:appcompat-v7:21.0.3'
    compile project(":PDFViewCtrlTools")
    compile('com.crashlytics.sdk.android:crashlytics:2.2.1') {
        transitive = true;
    }
}

android {
    compileSdkVersion 21
    buildToolsVersion "21.1.2"


    lintOptions {
        // If true, stop the gradle build if errors are found
        abortOnError false
        //ignore 'ValidFragment'
    }
}

This is my AndroidManifest.xml

        <activity
        android:name="com.ecrome.tabook.MainActivity"
        android:label="@string/app_name"
        android:launchMode="singleTop" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
        <meta-data
            android:name="io.fabric.ApiKey"
            android:value="xxxxxx" />
        </activity>

Any ideas why I'm getting the error and I'm not able to compile the app?

Gabriele Mariotti
  • 320,139
  • 94
  • 887
  • 841
Manuel Escrig
  • 2,825
  • 1
  • 27
  • 36

3 Answers3

2

Have two build.gradle In first of the project/build.gradle add:

buildscript {
    repositories {
      //ADD this Line
      maven { url 'https://maven.fabric.io/public' }
    }
    dependencies {
        //ADD this Line
        classpath 'io.fabric.tools:gradle:1.22.2'
    }
 }

And in second app/build.gradle

buildscript {
    repositories {
      //ADD this Line
      maven { url 'https://maven.fabric.io/public' }
    }
    dependencies {
        //ADD this Line
        classpath 'io.fabric.tools:gradle:1.22.2'
    }
 }

 apply plugin: 'io.fabric'

 repositories {
      maven { url 'https://maven.fabric.io/public' }
 }
 dependencies {
    compile('com.crashlytics.sdk.android:crashlytics:2.6.8@aar'){
         transitive = true;
    }
 }

AndroidManifest

<uses-permission android:name="android.permission.INTERNET" />

<application
    <meta-data
        android:name="io.fabric.ApiKey"
        android:value="yourKey" />
<application/>

MainActivity

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Fabric.with(this, new Crashlytics());
    setContentView(R.layout.activity_main);
}
Junior
  • 101
  • 7
0

Change this part, adding the @aar notation

compile('com.crashlytics.sdk.android:crashlytics:2.2.1@aar') {
        transitive = true;
    }

In this way you will download the aar artifact from the repo.

Gabriele Mariotti
  • 320,139
  • 94
  • 887
  • 841
  • I am trying to integrate Crashlytics into my library project, which is a separate project but referring the same into my main project. Facing the same issue! Please share if you have integrated Crashlytics into the library project successfully! – Paresh Mayani Sep 01 '15 at 12:23
  • I have also confirmed whether it's downloading AAR file into the library project's explored-aar folder, so it has the AAR file, but don't know why it's showing error that it couldn't found AAR file into the main project! – Paresh Mayani Sep 01 '15 at 12:43
  • Hi @PareshMayani!. The library has the aar. But how do you manage the main project? Has it a local dependency or a maven dependency with the library? – Gabriele Mariotti Sep 01 '15 at 12:46
  • The main project has a local dependency. – Paresh Mayani Sep 01 '15 at 12:53
  • I have got their documentation about setting up [Crashlytics into the library subprojects](https://docs.fabric.io/android/crashlytics/build-tools.html#setting-up-a-library-subproject), so it seems possible to integrate Crashlytics into the library project. And I have followed the steps mentioned in this doc too but again the same error! – Paresh Mayani Sep 01 '15 at 12:55
  • You have to define the same dependencies (not the configuration) in the main project. Using a local project (instead of a maven dependency), the main project doesn't have its dependencies. – Gabriele Mariotti Sep 01 '15 at 12:59
0

One mistake you did is that you have added meta-data inside of activity.

it should be outside of <activity tag and inside of <application tag

And make sure you have initialize fabrics once in Application or Activity startUp.

Fabric.with(mContext, new Crashlytics());
Zar E Ahmer
  • 33,936
  • 20
  • 234
  • 300