前提・実現したいこと
アプリに 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 を追加できたのですが、同じやり方でもこのアプリだけ追加がうまくいきません。
初学者のため、解決に必要な情報が足りていないかもしれません。
他に必要な情報がありましたら追記いたしますので、コメントいただけますと幸いです。
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。