46 votes

L'application Android ne se connecte pas à Firebase

Je développe une application Android en utilisant le service Firebase GMS.
J'ai essayé de suivre leurs tutoriels, j'ai fait le projet comme ils l'ont dit, j'ai téléchargé les fichiers json.

Mais quand j'ai essayé de connecter mon application à Firebase. Ils me montrent l'erreur

Impossible d'analyser la configuration Gradle du module d'application Android. Résolvez l'erreur de construction de Gradle et/ou resynchronisez.

enter image description here

Cependant je pense que mes scripts de notation sont parfaits ( je les écris en bas de page)

enter image description here

C'est ma console de construction de grade

Executing tasks: [:app:generateDebugSources, :app:mockableAndroidJar, :app:prepareDebugUnitTestDependencies, :app:generateDebugAndroidTestSources]

Configuration on demand is an incubating feature.
WARNING: WARNING: Dependency org.json:json:20090211 is ignored for debug as it may be conflicting with the internal version provided by Android.
         In case of problem, please repackage it with jarjar to change the class packages
WARNING: WARNING: Dependency org.json:json:20090211 is ignored for debug as it may be conflicting with the internal version provided by Android.
         In case of problem, please repackage it with jarjar to change the class packages
WARNING: WARNING: Dependency org.json:json:20090211 is ignored for debug as it may be conflicting with the internal version provided by Android.
         In case of problem, please repackage it with jarjar to change the class packages
WARNING: WARNING: Dependency org.json:json:20090211 is ignored for debug as it may be conflicting with the internal version provided by Android.
         In case of problem, please repackage it with jarjar to change the class packages
WARNING: WARNING: Dependency org.json:json:20090211 is ignored for release as it may be conflicting with the internal version provided by Android.
         In case of problem, please repackage it with jarjar to change the class packages
WARNING: WARNING: Dependency org.json:json:20090211 is ignored for release as it may be conflicting with the internal version provided by Android.
         In case of problem, please repackage it with jarjar to change the class packages
WARNING: WARNING: Dependency org.json:json:20090211 is ignored for release as it may be conflicting with the internal version provided by Android.
         In case of problem, please repackage it with jarjar to change the class packages
WARNING: WARNING: Dependency org.json:json:20090211 is ignored for release as it may be conflicting with the internal version provided by Android.
         In case of problem, please repackage it with jarjar to change the class packages
Incremental java compilation is an incubating feature.
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:checkDebugManifest
:app:preReleaseBuild UP-TO-DATE
:app:prepareComAndroidSupportAnimatedVectorDrawable2400Library UP-TO-DATE
:app:prepareComAndroidSupportAppcompatV72400Library UP-TO-DATE
:app:prepareComAndroidSupportMediarouterV72400Library UP-TO-DATE
:app:prepareComAndroidSupportPaletteV72400Library UP-TO-DATE
:app:prepareComAndroidSupportSupportV42400Library UP-TO-DATE
:app:prepareComAndroidSupportSupportVectorDrawable2400Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServices980Library
:app:prepareComGoogleAndroidGmsPlayServicesAds980Library
:app:prepareComGoogleAndroidGmsPlayServicesAdsLite980Library
:app:prepareComGoogleAndroidGmsPlayServicesAnalytics980Library
:app:prepareComGoogleAndroidGmsPlayServicesAnalyticsImpl980Library
:app:prepareComGoogleAndroidGmsPlayServicesAppindexing980Library
:app:prepareComGoogleAndroidGmsPlayServicesAppinvite980Library
:app:prepareComGoogleAndroidGmsPlayServicesAuth980Library
:app:prepareComGoogleAndroidGmsPlayServicesAuthBase980Library
:app:prepareComGoogleAndroidGmsPlayServicesAwareness980Library
:app:prepareComGoogleAndroidGmsPlayServicesBase980Library
:app:prepareComGoogleAndroidGmsPlayServicesBasement980Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesCast980Library
:app:prepareComGoogleAndroidGmsPlayServicesCastFramework980Library
:app:prepareComGoogleAndroidGmsPlayServicesClearcut980Library
:app:prepareComGoogleAndroidGmsPlayServicesDrive980Library
:app:prepareComGoogleAndroidGmsPlayServicesFitness980Library
:app:prepareComGoogleAndroidGmsPlayServicesGames980Library
:app:prepareComGoogleAndroidGmsPlayServicesGass980Library
:app:prepareComGoogleAndroidGmsPlayServicesGcm980Library
:app:prepareComGoogleAndroidGmsPlayServicesIdentity980Library
:app:prepareComGoogleAndroidGmsPlayServicesIid980Library
:app:prepareComGoogleAndroidGmsPlayServicesInstantapps980Library
:app:prepareComGoogleAndroidGmsPlayServicesLocation980Library
:app:prepareComGoogleAndroidGmsPlayServicesMaps980Library
:app:prepareComGoogleAndroidGmsPlayServicesNearby980Library
:app:prepareComGoogleAndroidGmsPlayServicesPanorama980Library
:app:prepareComGoogleAndroidGmsPlayServicesPlaces980Library
:app:prepareComGoogleAndroidGmsPlayServicesPlus980Library
:app:prepareComGoogleAndroidGmsPlayServicesSafetynet980Library
:app:prepareComGoogleAndroidGmsPlayServicesTagmanager980Library
:app:prepareComGoogleAndroidGmsPlayServicesTagmanagerApi980Library
:app:prepareComGoogleAndroidGmsPlayServicesTasks980Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesVision980Library
:app:prepareComGoogleAndroidGmsPlayServicesWallet980Library
:app:prepareComGoogleAndroidGmsPlayServicesWearable980Library
:app:prepareComGoogleFirebaseFirebaseAnalytics980Library UP-TO-DATE
:app:prepareComGoogleFirebaseFirebaseAnalyticsImpl980Library UP-TO-DATE
:app:prepareComGoogleFirebaseFirebaseAuth980Library
:app:prepareComGoogleFirebaseFirebaseAuthCommon980Library
:app:prepareComGoogleFirebaseFirebaseAuthModule980Library
:app:prepareComGoogleFirebaseFirebaseCommon980Library UP-TO-DATE
:app:prepareComGoogleFirebaseFirebaseConfig980Library
:app:prepareComGoogleFirebaseFirebaseCore980Library UP-TO-DATE
:app:prepareComGoogleFirebaseFirebaseCrash980Library
:app:prepareComGoogleFirebaseFirebaseDatabase980Library
:app:prepareComGoogleFirebaseFirebaseDatabaseConnection980Library
:app:prepareComGoogleFirebaseFirebaseIid980Library UP-TO-DATE
:app:prepareComGoogleFirebaseFirebaseMessaging980Library UP-TO-DATE
:app:prepareComGoogleFirebaseFirebaseStorage980Library
:app:prepareComGoogleFirebaseFirebaseStorageCommon980Library
:app:prepareComTsengvnTypekit100Library UP-TO-DATE
:app:prepareDebugDependencies
:app:compileDebugAidl UP-TO-DATE
:app:compileDebugRenderscript UP-TO-DATE
:app:generateDebugBuildConfig UP-TO-DATE
:app:generateDebugResValues UP-TO-DATE
:app:processDebugGoogleServices
Parsing json file: C:\Users\AJH322\AndroidStudioProjects\hanyang\app\src\debug\google-services.json
:app:generateDebugResources
:app:mergeDebugResources
:app:processDebugManifest
:app:processDebugResources
:app:generateDebugSources
:app:mockableAndroidJar UP-TO-DATE
:app:preDebugUnitTestBuild UP-TO-DATE
:app:prepareDebugUnitTestDependencies
:app:preDebugAndroidTestBuild UP-TO-DATE
:app:prepareDebugAndroidTestDependencies
:app:compileDebugAndroidTestAidl UP-TO-DATE
:app:processDebugAndroidTestManifest
:app:compileDebugAndroidTestRenderscript UP-TO-DATE
:app:generateDebugAndroidTestBuildConfig UP-TO-DATE
:app:generateDebugAndroidTestResValues UP-TO-DATE
:app:generateDebugAndroidTestResources UP-TO-DATE
:app:mergeDebugAndroidTestResources
:app:processDebugAndroidTestResources
:app:generateDebugAndroidTestSources

BUILD SUCCESSFUL

Total time: 3 mins 14.678 secs

et voici mon gradle script (module)

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "24.0.0"
    defaultConfig {
        applicationId "com.example.ajh322.hanyang"
        minSdkVersion 15
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.android.support:appcompat-v7:23.4.0'
    compile 'com.google.android.gms:play-services:9.8.0'
    compile 'com.tsengvn:Typekit:1.0.0'
    compile 'com.squareup.okhttp3:okhttp:3.4.2'
    compile 'com.github.nkzawa:socket.io-client:0.3.0'
    testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'

projet gradle appliquer le plugin : com.Android.application

android {
    compileSdkVersion 23
    buildToolsVersion "24.0.0"
    defaultConfig {
        applicationId "com.example.ajh322.hanyang"
        minSdkVersion 15
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.android.support:appcompat-v7:23.4.0'
    compile 'com.google.android.gms:play-services:9.8.0'
    compile 'com.tsengvn:Typekit:1.0.0'
    compile 'com.squareup.okhttp3:okhttp:3.4.2'
    compile 'com.github.nkzawa:socket.io-client:0.3.0'
    testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'

Quelqu'un sait-il comment je peux me connecter à Firebase avec mon application ?
s'il vous plaît, sauvez ma vie... merci

+ J'ai mis à jour mes outils SDK comme on me l'a dit.
ne fonctionne toujours pas.
enter image description here

39voto

jsha Points 857

J'ai eu exactement le même problème. J'ai réussi à construire mais j'ai eu le même message lorsque j'ai appuyé sur le bouton "Connecter à Firebase" via l'assistant.

Il s'est avéré que j'avais un avertissement que je devais corriger pour que ça fonctionne.

" La configuration à la demande est une fonctionnalité en cours d'incubation. ATTENTION : La configuration 'compile' est obsolète et a été remplacée par 'implementation' et 'api'. Elle sera supprimée à la fin de l'année 2018. Pour plus d'informations, voir : http://d.Android.com/r/tools/update-dependency-configurations.html "

J'ai juste dû remplacer mes "compile" par des "api" et ça a marché. Je vous suggère de chercher à corriger les avertissements si vous en avez, même si votre compilation est réussie.

1 votes

Merci. Dans mon cas, j'ai dû utiliser "implementation" au lieu de "compile".

0 votes

Cela fonctionne pour moi avec cette ligne //jackOptions {enabled true}

18voto

Doan Bui Points 217

J'ai essayé de nombreuses façons, mais la plus simple est de mettre à jour com.google.gms:google-services de 3.1.1 à 3.2.0

8voto

Nicholas Points 705

Je soupçonne les gzips de votre projet d'être les coupables. Cherchez dans le dossier de votre projet et supprimez-les, laissez gradle le re-synchroniser pour vous.

Solutions alternatives possibles : https://github.com/socketio/engine.io-client-java/issues/13 https://github.com/ACRA/acra/issues/159

0 votes

Je pensais que ces avertissements n'avaient rien à voir avec la base de feu, mais merci encore.

2 votes

@AJH ce qui est gzips J'ai le même problème et je n'arrive pas à le résoudre ?

1 votes

@Nicholas qu'est-ce que gzips ?

6voto

Nox Fortes Points 41

Allez dans le fichier build.gradle de l'application. Remplacez "compile" par "api". Ensuite, synchronisez votre projet. L'avertissement devrait disparaître. Cela a bien fonctionné pour moi.

3voto

Mystery Points 94

Dans le fichier build.gradle, remplacez 'compile' par 'implementation' et synchronisez le projet.

Prograide.com

Prograide est une communauté de développeurs qui cherche à élargir la connaissance de la programmation au-delà de l'anglais.
Pour cela nous avons les plus grands doutes résolus en français et vous pouvez aussi poser vos propres questions ou résoudre celles des autres.

Powered by:

X