I am trying to add firebase to my app and followed every step as told in https://firebase.google.com/docs/android/setup but as soon as a launch the app it crashes with the error
E/AndroidRuntime: FATAL EXCEPTION: main Process: com.example.examplefirestore, PID: 29977 java.lang.BootstrapMethodError: Exception from call site #8 bootstrap method at com.google.firebase.components.ComponentDiscovery.discoverLazy(ComponentDiscovery.java:112) at com.google.firebase.FirebaseApp.<init>(FirebaseApp.java:418) at com.google.firebase.FirebaseApp.initializeApp(FirebaseApp.java:299) at com.google.firebase.FirebaseApp.initializeApp(FirebaseApp.java:267) at com.google.firebase.FirebaseApp.initializeApp(FirebaseApp.java:252) at com.google.firebase.provider.FirebaseInitProvider.onCreate(FirebaseInitProvider.java:51) at android.content.ContentProvider.attachInfo(ContentProvider.java:1919) at android.content.ContentProvider.attachInfo(ContentProvider.java:1894) at com.google.firebase.provider.FirebaseInitProvider.attachInfo(FirebaseInitProvider.java:45) at android.app.ActivityThread.installProvider(ActivityThread.java:6391) at android.app.ActivityThread.installContentProviders(ActivityThread.java:5938) at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5853) at android.app.ActivityThread.access$1100(ActivityThread.java:199) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1650) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:193) at android.app.ActivityThread.main(ActivityThread.java:6669) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858) Caused by: java.lang.ClassCastException: Bootstrap method returned null at com.google.firebase.components.ComponentDiscovery.discoverLazy(ComponentDiscovery.java:112) at com.google.firebase.FirebaseApp.<init>(FirebaseApp.java:418) at com.google.firebase.FirebaseApp.initializeApp(FirebaseApp.java:299) at com.google.firebase.FirebaseApp.initializeApp(FirebaseApp.java:267) at com.google.firebase.FirebaseApp.initializeApp(FirebaseApp.java:252) at com.google.firebase.provider.FirebaseInitProvider.onCreate(FirebaseInitProvider.java:51) at android.content.ContentProvider.attachInfo(ContentProvider.java:1919) at android.content.ContentProvider.attachInfo(ContentProvider.java:1894) at com.google.firebase.provider.FirebaseInitProvider.attachInfo(FirebaseInitProvider.java:45) at android.app.ActivityThread.installProvider(ActivityThread.java:6391) at android.app.ActivityThread.installContentProviders(ActivityThread.java:5938) at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5853) at android.app.ActivityThread.access$1100(ActivityThread.java:199) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1650) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:193) at android.app.ActivityThread.main(ActivityThread.java:6669) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
I have also cross checked my gradle moudle and every thing seems to be fine, here is my gradle module
apply plugin: 'com.android.application' apply plugin: 'com.google.gms.google-services' android { compileSdkVersion 30 buildToolsVersion "30.0.1" defaultConfig { applicationId "com.example.examplefirestore" minSdkVersion 24 targetSdkVersion 30 versionCode 1 versionName "1.0" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } } } dependencies { implementation fileTree(dir: "libs", include: ["*.jar"]) implementation 'androidx.appcompat:appcompat:1.3.0' implementation 'androidx.constraintlayout:constraintlayout:2.0.4' testImplementation 'junit:junit:4.12' androidTestImplementation 'androidx.test.ext:junit:1.1.2' androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0' implementation platform('com.google.firebase:firebase-bom:28.1.0') implementation 'com.google.firebase:firebase-analytics' implementation 'com.google.firebase:firebase-firestore' }
Even in graple project everything seems to be ok to me i have cross checked this multiple times, this is my gradle project
// Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { repositories { google() jcenter() } dependencies { classpath "com.android.tools.build:gradle:4.0.2" classpath 'com.google.gms:google-services:4.3.8' // 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 }
Advertisement
Answer
It seems like you are missing
compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 }
in your build.gradle (app).