web-dev-qa-db-fra.com

plug-in Fabric Android Studio non trouvé importer com.crashlytics & io.fabric

Sur mon nouveau projet, j'aimerais intégrer Crashlytics de Fabric.io

J'ai déjà installé Fabric sur d'autres projets sans problème, un projet avec le tutoriel ici: https://fabric.io/kits/Android/crashlytics/install

Et sur l'autre projet, j'ai utilisé le plugin Fabric intégré à Android Studio (photo)  enter image description here

voici le problème: 

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.

mon build.gradle (projet): 

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;
//    }

}

J'ai changé compileSdkVersion 23 à 24 mais rien n'a changé, quelqu'un a eu ce problème?

Merci d'avance pour votre aide :)


J'ai oublié une ligne 

Maintenant ça marche ! désolé pour le désagrément ^^ '

7
bzhWarrior

Mike de Fabric ici.

Il semble que vous ayez commenté toute l’initialisation de Fabric dans votre build.gradle? Si vous commentez les lignes ci-dessous, cela devrait fonctionner. 

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;
}

Le build.gradle complet aurait toutes les modifications suivantes :

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;
  }
11
Mike Bonnell

effacer et reconstruire et redémarrer Android Studio Son fonctionnement

 enter image description here

projet build.gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {

    repositories {
        google()
        jcenter()
    }


    buildscript {
        repositories {
            jcenter()
            mavenCentral()
            maven { url 'https://maven.fabric.io/public' }
        }
        dependencies {
            classpath 'io.fabric.tools:gradle:1.+'
        }
    }

    dependencies {
        classpath 'com.Android.tools.build:gradle:3.0.1'
        classpath 'io.fabric.tools:gradle:1.+'


        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}


allprojects {
    repositories {
        google()
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

module build.gradle

apply plugin: 'com.Android.application'
apply plugin: 'io.fabric'

Android {
    compileSdkVersion 26
    defaultConfig {
        applicationId "com.holostik.ozoneoverseas"
        minSdkVersion 15
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "Android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-Android.txt'), 'proguard-rules.pro'
        }
    }
}

Android {
    defaultConfig {
        multiDexEnabled true
    }
}

dependencies {
    // TODO FCM
//    implementation 'com.google.firebase:firebase-messaging:11.0.4'
//compile 'com.google.firebase:firebase-messaging:11.0.4'

    compile fileTree(include: ['*.jar'], dir: 'libs')
    androidTestCompile('com.Android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.Android.support', module: 'support-annotations'
    })
    //    compile 'com.Android.support:appcompat-v7:26.+'
    compile 'com.Android.support:appcompat-v7:26.0.1'
    compile 'com.Android.support.constraint:constraint-layout:1.0.2'
    testCompile 'junit:junit:4.12'
    compile 'me.dm7.barcodescanner:zxing:1.9.7'
    compile 'com.Android.support:cardview-v7:26.0.1'
    compile 'com.Android.support:design:26.0.1'
    compile 'com.github.bumptech.glide:glide:3.7.0'
    compile 'de.hdodenhof:circleimageview:1.3.0'
    compile 'com.Android.volley:volley:1.0.0'
//    compile 'com.google.Android.gms:play-services-location:7.8.0'     // TODO Previous working
//    compile 'com.google.Android.gms:play-services-location:9.0.0'
    compile 'com.google.Android.gms:play-services-location:11.0.4'
//    compile "com.google.Android.gms:play-services-gcm:9.2.0"

    compile 'com.squareup.retrofit2:retrofit:2.1.0'
    compile 'com.squareup.retrofit2:converter-gson:2.1.0'
    compile 'com.Android.volley:volley:1.0.0'
    compile 'com.theartofdev.edmodo:Android-image-cropper:2.3.+'
    //TODO camera Crop dependency working
//    compile files('libs/ksoap2-Android-Assembly-2.5.7-jar-with-dependencies.jar')

//    implementation 'com.google.firebase:firebase-messaging:11.0.4'

//    compile 'com.google.Android.gms:play-services:11.4.0'
    compile 'com.google.Android.gms:play-services:11.0.4'

    //    compile 'com.facebook.Android:facebook-Android-sdk:4.8.0'           // Works here
    compile 'com.facebook.Android:facebook-Android-sdk:4.13.1'           // Works here
    compile('com.crashlytics.sdk.Android:crashlytics:2.9.0@aar') {
        transitive = true;
    }
    compile('com.crashlytics.sdk.Android:crashlytics-ndk:2.0.2@aar') {
        transitive = true;
    }


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

}

allprojects {
    repositories {
        jcenter()
        maven {
            url "https://maven.google.com"
        }
    }
}




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

    // ...
    dependencies {
        // ...
        classpath 'com.google.gms:google-services:3.1.1' // google-services plugin
        classpath 'io.fabric.tools:gradle:1.+'
    }
}

allprojects {
    // ...
    repositories {
        // ...
        maven {
            url "https://maven.google.com" // Google's Maven repository
        }
    }
}*/
// TODO FCM
//apply plugin: 'com.google.gms.google-services' // TODO FCM add auto in Bottom  When Google Service Add uncomment this

//dependencies {
//    implementation fileTree(dir: 'libs', include: ['*.jar'])
//    implementation 'com.Android.support:appcompat-v7:26.1.0'
//    implementation 'com.Android.support.constraint:constraint-layout:1.0.2'
//    testImplementation 'junit:junit:4.12'
//    androidTestImplementation 'com.Android.support.test:runner:1.0.1'
//    androidTestImplementation 'com.Android.support.test.espresso:espresso-core:3.0.1'
//}



crashlytics {
    enableNdk true
    androidNdkOut 'src/main/obj'
    androidNdkLibsOut 'src/main/libs'
}

manifest.xml

    <meta-data
        Android:name="io.fabric.ApiKey"
        Android:value="1864e6d3e59158a5206d2d073e7e14c7ad811cbd" />

Activité Splash

 @Override
 public void onCreate(Bundle savedInstanceState) 
 {
     super.onCreate(savedInstanceState);
     Fabric.with(this, new Crashlytics(), new CrashlyticsNdk());
 }
2
Keshav Gera