簡體   English   中英

Android App + Firebase初始化失敗

[英]Android App + Firebase initializations fail

對於我的Android應用,我需要集成Firebase。 所以我遵循了谷歌教程。

現在我總是在實施firebase后得到

E/FirebaseApp: Firebase API initialization failure.

當我運行應用程序時(在真實設備和仿真上)

已經看到: Firebase數據庫依賴項使應用程序崩潰,但他正在使用舊版本...

所以我的依賴關系如下所示:

   dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    //noinspection GradleCompatible
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    implementation 'com.google.android.gms:play-services-location:16.0.0'
    //implementation 'com.google.android.gms:play-services:12.0.1'
    implementation 'com.google.firebase:firebase-core:16.0.5'
}
apply plugin: 'com.google.gms.google-services'

這里的項目gradle:

buildscript {

    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.1'
        classpath 'com.google.gms:google-services:4.0.1'



    }
}

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

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

有誰知道該怎么做才能消除這個初始化問題?

我認為,不要添加“ com.google.android.gms:play-services:”,而是確定playservices需要什么。 由於Play服務中塞滿了22個程序包,因此您可能不會使用所有程序包。 這將使apk大小膨脹,並且您的項目中可能會越過65K個方法

我建議您通過此鏈接從playservices中選擇所需的必要內容。

暫無
暫無

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

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