質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Firebase

Firebaseは、Googleが提供するBasSサービスの一つ。リアルタイム通知可能、並びにアクセス制御ができるオブジェクトデータベース機能を備えます。さらに認証機能、アプリケーションのログ解析機能などの利用も可能です。

Kotlin

Kotlinは、ジェットブレインズ社のアンドリー・ブレスラフ、ドミトリー・ジェメロフが開発した、 静的型付けのオブジェクト指向プログラミング言語です。

Q&A

解決済

2回答

1707閲覧

Default Firebaseapp Is Not Initialized In This Processでアプリが落ちる

Aki_1988

総合スコア44

Firebase

Firebaseは、Googleが提供するBasSサービスの一つ。リアルタイム通知可能、並びにアクセス制御ができるオブジェクトデータベース機能を備えます。さらに認証機能、アプリケーションのログ解析機能などの利用も可能です。

Kotlin

Kotlinは、ジェットブレインズ社のアンドリー・ブレスラフ、ドミトリー・ジェメロフが開発した、 静的型付けのオブジェクト指向プログラミング言語です。

0グッド

0クリップ

投稿2019/05/07 16:52

前提・実現したいこと

アプリに Firebase を追加したい。
しかし、 アプリを実行してインストールを確認 から進まなくなってしまった。

発生している問題・エラーメッセージ

アプリ起動時に以下エラー。

Default FirebaseApp is not initialized in this process

該当のソースコード

app.gradle

apply plugin: 'com.android.application' apply plugin: 'kotlin-android' apply plugin: 'kotlin-android-extensions' android { compileSdkVersion 28 defaultConfig { applicationId "com.aki.projectName" minSdkVersion 16 targetSdkVersion 28 versionCode 1 versionName "1.0" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } } dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" implementation 'androidx.appcompat:appcompat:1.0.2' implementation 'androidx.constraintlayout:constraintlayout:2.0.0-alpha5' implementation 'com.google.android.material:material:1.0.0' implementation 'com.android.support:recyclerview-v7:28.0.0' implementation 'com.google.firebase:firebase-core:16.0.8' implementation 'com.google.firebase:firebase-firestore:15.0.0' testImplementation 'junit:junit:4.12' androidTestImplementation 'androidx.test:runner:1.2.0-alpha05' androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0-alpha05' } apply plugin: 'com.google.gms.google-services'

projectName.gradle

buildscript { ext.kotlin_version = '1.3.10' repositories { google() jcenter() } dependencies { classpath 'com.android.tools.build:gradle:3.2.1' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath 'com.google.gms:google-services:4.2.0' // 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 }

試したこと

FirebaseApp.initializeApp(this)FirebaseFirestore.getInstance() 前に追加。

MainActivity の OnCreate

FirebaseApp.initializeApp(this); FirebaseFirestore.getInstance()

Run すると以下エラー

java.lang.IllegalStateException: A required meta-data tag in your app's AndroidManifest.xml does not exist. You must have the following declaration within the <application> element: <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />

試したこと 2

application に以下を追加。

<application> <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" /> </application>

これでも解決できず。

補足情報(FW/ツールのバージョンなど)

別のアプリでは、正常に Firebase を追加できたのですが、同じやり方でもこのアプリだけ追加がうまくいきません。
初学者のため、解決に必要な情報が足りていないかもしれません。
他に必要な情報がありましたら追記いたしますので、コメントいただけますと幸いです。

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答2

0

自己解決

以下サイトを参考に AndroidManifest.xm のl tools:node="replace" を削除したところ表題のエラーは発生しなくなった。しかし、firebase コンソールではいまだ通信確認ができていない状態になっている。
https://stackoverflow.com/questions/40081539/default-firebaseapp-is-not-initialized

投稿2019/05/14 09:41

Aki_1988

総合スコア44

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

0

Googleサービスのバージョンに互換性の問題があるように思います。
試したことを一旦もとに戻して、projectName.gradle内のバージョンを次のように調整してみてください。

buildscript { dependencies { classpath 'com.android.tools.build:gradle:3.2.1' classpath 'com.google.gms:google-services:4.1.0' } }

または

buildscript { dependencies { classpath 'com.android.tools.build:gradle:3.3.1' classpath 'com.google.gms:google-services:4.2.0' } }

ついでにfirestoreのバージョンも15.0.0から18.1.0とかに上げておくと良いでしょう。
https://firebase.google.com/docs/android/setup#available-libraries

投稿2019/05/10 21:30

xenbeat

総合スコア4258

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

Aki_1988

2019/05/12 13:51

コメントありがとうございます。 試してみたところ、前者のほうは表題のエラーが発生しており、後者のほうは ``` Could not resolve all artifacts for configuration ':classpath'. > Could not download builder.jar (com.android.tools.build:builder:3.3.1) > Could not get resource 'https://dl.google.com/dl/android/maven2/com/android/tools/build/builder/3.3.1/builder-3.3.1.jar'. > Could not GET 'https://dl.google.com/dl/android/maven2/com/android/tools/build/builder/3.3.1/builder-3.3.1.jar'. > Connect to dl.google.com:443 [dl.google.com/172.217.161.46, dl.google.com/172.217.161.78, dl.google.com/2404:6800:4004:80b:0:0:0:200e] failed: Bad file descriptor (connect failed) ``` のエラーが発生してしまいました。 もしその他に確認事項がありますでしょうか。返信いただけますと幸いです。
xenbeat

2019/05/12 14:48

本題のエラーが解決できたのであれば、お手数ですが本質問をクローズして別途質問をオープンしていただけますでしょうか。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問