簡體   English   中英

Android 應用程序未連接到 Firebase

[英]Android app does not connect to Firebase

我正在使用 Firebase GMS 服務開發 android 應用程序。
我嘗試按照他們的教程進行操作,按照他們的說法制作項目,下載了 json 文件。

但是當我嘗試將我的應用程序連接到 Firebase 時。 他們向我展示了錯誤

無法解析 Android 應用模塊的 Gradle 配置。 解決 gardle 構建問題和/或重新同步。

在此處輸入圖像描述

但是我認為我的成績單很完美(我會寫在頁面底部)

在此處輸入圖像描述

這是我的成績構建控制台

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

這是我的 gradle 腳本(模塊)

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'

項目 gradle 應用插件:'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'

有人知道如何使用我的應用程序連接到 Firebase 嗎?
請拯救我的生命...謝謝



+ 正如人們所說,我更新了我的 sdk 工具
仍然無法正常工作。
在此處輸入圖像描述

我有完全相同的問題。 我構建成功,但在通過助手點擊“連接到 Firebase”按鈕時收到了相同的消息。

結果是我有一個警告,我必須修復它才能讓它工作。

“按需配置是一個孵化功能。警告:配置'編譯'已過時,已被'實現'和'api'取代。它將在2018年底刪除。更多信息參見: http://d .android.com/r/tools/update-dependency-configurations.html "

我只需要用'api'替換我的'compile',然后它就可以工作了。 即使您的構建成功,我也建議您查看修復警告,如果您有任何警告。

我嘗試了很多方法,但最簡單的方法是將com.google.gms:google-services從 3.1.1 更新為 3.2.0

我懷疑您項目中的 gzip 可能是罪魁禍首。 在您的項目文件夾中搜索並刪除它們,讓 gradle 為您重新同步它。

可能的替代解決方案: https : //github.com/socketio/engine.io-client-java/issues/13 https://github.com/ACRA/acra/issues/159

確保您的 app/build.gradle 沒有過時的依賴項和聲明。 我的問題是使用

dataBinding {
    enabled = true
}

而不是

buildFeatures{
        dataBinding = true
    }

轉到應用程序 build.gradle 文件。 將“編譯”替換為“api”。 然后,同步您的項目。 警告應該消失。 這對我來說很好。

好吧,您需要解決所有 gradle 構建問題。 轉到 gradle 控制台(通常位於 IDE 的右下角)並檢查它們的錯誤/警告。 一旦您的構建成功且沒有錯誤,與 firebase 的連接應該可以工作。

我最近更新到 Android studio 4.0 並遇到了這個錯誤。 我仍然使用過時的方式來添加數據綁定。 將其更改為使用數據綁定的更新方式解決了我的問題。 下面是代碼:

buildFeatures{
        dataBinding = true
        // for view binding :
        // viewBinding = true
    }

在 build.gradle 文件中,將 'compile' 替換為 'implementation' 並同步項目。

我在 build.gradle 文件中有一些其他錯誤。 注釋掉以下行后,它開始工作:

dexOptions
            {
                //incremental false
            }

就我而言,它顯示了此警告:

API 'variant.getMergeResources()' is obsolete and has been replaced with 'variant.getMergeResourcesProvider()

因此,我無法連接到 Firebase。

由 gms 服務 4.3.0 引起。 所以我不得不將其更改為:

com.google.gms:google-services:4.2.0

我通過運行發現了這一點:

gradlew 同步 -Pandroid.debug.obsoleteApi=true

在終端。 在 Android Studio 中轉到查看 -> 工具窗口 -> 終端。 Gms 服務可能會在未來的版本中解決這個問題。

第一種方法:- 只需刪除jcenter() 因為此存儲庫即將關閉,因此這將在與 firebase 連接時產生問題

repositories {
        google()
        mavenCentral()
//        jcenter() // Warning: this repository is going to shut down soon
    }

第二種方法:- 臨時刪除

id 'androidx.navigation.safeargs.kotlin' 

在 build.gradle(module) 和

classpath "androidx.navigation:navigation-safe-args-gradle-plugin:2.3.5" 

來自 build.gradle(項目)

如果您正在使用,請注意:

android.enableR8 = 真

暫時刪除它。 那是我的錯誤。

如果您正在使用 gradle.properties 中的databinding ,請刪除此行

android.databinding.enableV2=true

在build.gradle(Module.app)中,如果使用視圖綁定,暫時注釋掉,然后同步!

/*
viewBinding {
   enabled = true
}
*/

然后連接到firebase。 我使用 AS 4.0。

我有同樣的問題! 當我使用 Android Studio Firebase 助手並單擊“連接到 Firebase”按鈕時,我遇到了同樣的問題。 解決方法很簡單:忘記助手(很明顯,它有一些bug),只需按照說明手動將Firebase項目集成到您的Android Studio項目中(在Firebase控制台中創建項目,下載json文件並將其放入'app' 文件夾內等)不要忘記確保所有 Firebase 依賴項的版本相同(例如 11.8.0)。 它對我有用。

對我來說,解決方案是,將所有“編譯'com.google ....”替換為“實現'com.google ...”

在 Gradle 文件中:

apply plugin: 'com.google.gms.google-services'

這對我有幫助。

好吧,您需要從 build.gradle 中刪除錯誤和警告。

可以在以下位置輕松找到:構建選項卡(底部)-> 同步選項卡-> 在這里您可以找到問題

任何有這個問題的人,我都是這樣解決的:Android Studio - 3.4.2

修復“構建”窗口中的所有警告。 將編譯更改為“implementation”和“testImplementation”、“androidTestImplementation”等

刪除這一行 app build.gradle: apply plugin: 'io.fabric'

就我而言,在我的清單中刪除節點

 <application
        android:name=".controller.AppController"
        android:allowBackup="false"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:usesCleartextTraffic="true"
        android:roundIcon="@mipmap/ic_launcher"
        android:supportsRtl="true"
        tools:node="replace"
        android:theme="@style/AppTheme">

刪除這一行

 tools:node="replace"

並用這個替換

tools:replace="allowBackup"

如果您正在使用 gradle.properties 中的數據綁定,請刪除此行

android.databinding.enableV2=true

已經在應用程序 gradle 文件中啟用了數據綁定

我有同樣的問題。 我通過將 sha-1 代碼更新到 firebase 控制台並從 firebase 重新導入 google-json 文件來解決它。 我發現的主要問題是在更新 android studio 后,sha-1 或 md5 代碼發生了變化。

在 build.gradle 文件中,將 'compile' 替換為 'implementation' 並同步項目。 以后謝謝我。

要在 Android Studio 北極狐中為新創建的 android 項目修復此問題,請更改所有測試依賴項的“testImplementation”、“androidTestImplementation”。

Couldn't parse the android application module Gradle config then there must be some problem in your grade build, In my case, I imported an old project which wasn't using android X, so I migrate to android X, and in the process,您還必須在gradle.properties文件中添加這些代碼行,

android.enableJetifier=true
android.useAndroidX=true
  • 我已更改為 android x,但未將這些設置為 true,為什么我收到錯誤,您可以從此處了解有關遷移到 android X 的更多信息,

https://developer.android.com/jetpack/androidx/migrate

我通過刪除解決了這個問題:

androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'

我希望這有效!

我遇到了同樣的問題,但至少我設法解決了它和最好的方法:

請更改應用模塊的 Gradle 配置:

在 Android 中:compileSdk 31 ---更改您的 SDK 版本,就像在我的項目中一樣,我使用 31

在 compileOptions{} 之后添加:

compileSdkVersion 31 ---將此代碼添加到您的 buildToolsVersion '30.0.3' ---將此代碼添加到您的

在依賴項中添加: implementation 'androidx.appcompat:appcompat:1.4.2' ---更改您的依賴項

現在同步您的項目 Firebase 控制台將打開……

視頻鏈接: https://youtu.be/trQtxMbMLFk

許多人已經提供了解決方案。 但有趣的是,問題的位置在我的情況下是不同的。 settings.gradle文件中注釋掉jcenter()為我解決了這個問題。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM