bzhWarrior bzhWarrior - 2 months ago 99
Android Question

plugin Fabric Android Studio not found import com.crashlytics & io.fabric

On my new project i would like to integrate Crashlytics from Fabric.io

I've already installed Fabric on others projects without issue, one project with the tutorial here : https://fabric.io/kits/android/crashlytics/install

And on the other project, I've using the plugin Fabric integrated into Android Studio (picture) enter image description here

here's the problem :

import android.app.Application;
import com.crashlytics.android.Crashlytics;
import io.fabric.sdk.android.Fabric;

public class UILApplication extends Application {

@Override
public void onCreate() {
super.onCreate();
Fabric.with(this, new Crashlytics()); // Fabric not found
}
}


Error:(6, 31) error: package com.crashlytics.android does not exist
Error:(7, 29) error: package io.fabric.sdk.android does not exist
Error:(20, 31) error: cannot find symbol class Crashlytics
Error:(20, 9) error: cannot find symbol variable Fabric
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
:app:compileDebugJavaWithJavac FAILED
Error:Execution failed for task ':app:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.


my build.gradle (Project) :

task wrapper(type: Wrapper) {
gradleVersion = '2.12'
}


build.gradle (Module:app) :

buildscript {
repositories {
mavenCentral()
maven { url "http://oss.sonatype.org/content/repositories/snapshots/" }
// maven { url 'https://maven.fabric.io/public' } THIS LINE FORGOTTEN
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.2'
classpath 'com.google.gms:google-services:3.0.0'
//classpath 'io.fabric.tools:gradle:1.+'
}
}

apply plugin: "com.android.application"
//apply plugin: 'io.fabric'

repositories {
mavenCentral()
maven { url "http://oss.sonatype.org/content/repositories/snapshots/" }
// maven { url 'https://maven.fabric.io/public' }
}
android {
compileSdkVersion = 24
buildToolsVersion = "23.0.3"

defaultConfig {
applicationId "agemos.testkalman1"
minSdkVersion 15
targetSdkVersion 24
versionCode 1
versionName "1.0"
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}


dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:24.2.0'
compile 'com.android.support:design:24.2.0'

compile ('com.mapbox.mapboxsdk:mapbox-android-sdk:4.2.0-SNAPSHOT@aar'){
transitive=true
}
// // Crashlytics Fabric io
// compile('com.crashlytics.sdk.android:crashlytics:2.6.3@aar') {
// transitive = true;
// }

}


I've change compileSdkVersion 23 to 24 but nothing has changed, someone had this problem ?

Thanks in advance for your help :)




I've forgot one line

Now it works ! sorry for the inconvenience ^^'

Answer

Mike from Fabric here.

It appears that you've commented out all initialization of Fabric in your build.gradle? If you un-comment the lines below, that should work.

classpath 'io.fabric.tools:gradle:1.+'

apply plugin: 'io.fabric'


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


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

The full build.gradle would have all of the following changes:

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

  dependencies {
    // The Fabric Gradle plugin uses an open ended version to react
    // quickly to Android tooling updates
    classpath 'io.fabric.tools:gradle:1.+'
  }
}

apply plugin: 'io.fabric'

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



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