Cloth with Android Studio

I am trying to install Crashlytics trough cloth in an Android Studio project . I am running 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 am getting the error and I am unable to compile the application?

+3


source to share


3 answers


There are two build.gradle At the beginning 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 the 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);
}

      

+1


source


Modify this part by adding the notation @aar

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

      



This way you will download the aar artifact from the repo.

0


source


One mistake you made was adding metadata inside your activity.

it must be outside the tag <activity

and inside the tag<application

And make sure you initialize fabrics once in your application or in Activity start.pp.

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

      

0


source







All Articles