Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Studio 1.1.0 - Error while adding Fabric Crashlytics to app

I've been trying to add Crashlytics to an app I'm developing on Android Studio 1.1.0 with no luck. I've added the Fabric plugin to Android Studio and when adding my app, the Crashlytics library is not recognized.

Here is the code added by Fabric:

...
import com.crashlytics.android.Crashlytics; // Error here
import io.fabric.sdk.android.Fabric; // Error here
...

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Fabric.with(this, new Crashlytics()); // Error here
    setContentView(R.layout.activity_main);
    ...
}

And here are the errors:

C:\Workspace\Projects\AndroidG\Borgertip\borgertip\src\main\java\dk\gis34\borgertip\activity\MainActivity.java
Error:(12, 31) error: package com.crashlytics.android does not exist
Error:(16, 29) error: package io.fabric.sdk.android does not exist
Error:(67, 31) error: cannot find symbol class Crashlytics
Error:(67, 9) error: cannot find symbol variable Fabric

Can a kind soul figur out why this doesn't just work, like it does on Eclipse?

like image 622
Ambran Avatar asked Apr 04 '15 21:04

Ambran


1 Answers

You should have these lines in your build.gradle file:

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

and this

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

    dependencies {
       // ...
       classpath 'io.fabric.tools:gradle:1.14.3'
    }
}
like image 110
ViliusK Avatar answered Oct 09 '22 17:10

ViliusK