java - FirebaseApp 初始化不成功 - 错误崩溃应用程序
问题描述
在我尝试初始化它崩溃的两个引用之后,在我的主要活动中,只是发现错误“FirebaseApp 初始化不成功”
private StorageReference mStorageReference;
private DatabaseReference mDatabaseReference;
mStorageReference = FirebaseStorage.getInstance().getReference("uploads");
mDatabaseReference = FirebaseDatabase.getInstance().getReference("uploads");
私有声明和代码本身之间有一些代码,但这与这个问题无关
清单是:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.firebase10">
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="android.permission.INTERNET"/>
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
build.gradle(项目):
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.1'
classpath 'com.google.gms:google-services:4.1.0'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
build.gradle(app):
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.firebase10"
minSdkVersion 19
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner
"android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-
optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
api "com.google.android.gms:play-services-base:15.0.1"
api "com.google.android.gms:play-services-auth:16.0.0"
api "com.google.android.gms:play-services-identity:15.0.1"
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation "com.android.support:customtabs:28.0.0"
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.google.firebase:firebase-database:16.0.1'
implementation 'com.google.firebase:firebase-storage:16.0.1'
implementation 'com.google.firebase:firebase-auth:16.0.3'
implementation 'com.android.support:recyclerview-v7:28.0.0'
implementation 'com.android.support:cardview-v7:28.0.0'
implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'com.google.gms:google-services:4.2.0'
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'
}
我使用 Tools-Firebase 设置了所有内容,并且我知道代码看起来像是粘在一起的,因为它是。我一直在经历线程,只是添加了一些东西,但没有任何效果。如果这很重要,我在手机上运行应用程序,而不是模拟器。
解决方案
在 build.gradle(Project) 我将'com.google.gms:google-services:4.1.0'更改为'com.google.gms:google-services:4.2.0'问题就解决了
推荐阅读
- haskell - Haskell中有一个空字符吗?
- java - Java Spring Data JPA 和 REST API:排除嵌套 JSON 对象的字段
- javascript - 点击获取边框时反应图像
- javascript - HTML 使任务栏和选项卡中的 Google Chrome 图标闪烁,并发送桌面通知
- reactjs - 如何使用 React 在 Apollo 客户端中交互 Query 和 Mutation
- c - C 代码编译没有错误但运行不正确(命令行参数和指针)
- github - 如何将来自 github 的代码与 Visual Studio 一起使用?
- python - 如何将 feed_dict 与 Tensorflow 层的输出一起使用?
- json - 在 Google 地球引擎中:最有效地减少 ImageCollection 中每个图像的区域,将均值保存为特征属性?
- python-3.x - 如何在 python 3.7 中创建新对象时使用“类型提示 - PEP 484”以便能够在 pycharm 2019.2.4 中完成代码