-
Notifications
You must be signed in to change notification settings - Fork 643
Closed
Labels
Description
Describe your environment
- Android Studio version: 2020.3.1 Patch 3 (Arctic Fox)
- Firebase Component: Performance
- Component version: 20.0.0 (usage through BOM 28.0.0)
Describe the problem
Getting this crash when running instrumented unit tests:
java.lang.IllegalStateException: Default FirebaseApp is not initialized in this process com.hadisatrio.apps.android.repro.test. Make sure to call FirebaseApp.initializeApp(Context) first.
at com.google.firebase.FirebaseApp.getInstance(FirebaseApp.java:183)
at com.google.firebase.perf.FirebasePerformance.getInstance(FirebasePerformance.java:132)
at com.google.firebase.perf.FirebasePerformanceInitializer.onAppColdStart(FirebasePerformanceInitializer.java:29)
at com.google.firebase.perf.application.AppStateMonitor.sendAppColdStartUpdate(AppStateMonitor.java:274)
at com.google.firebase.perf.application.AppStateMonitor.onActivityResumed(AppStateMonitor.java:195)
at android.app.Application.dispatchActivityResumed(Application.java:455)
at android.app.Activity.dispatchActivityResumed(Activity.java:1295)
at android.app.Activity.onResume(Activity.java:1827)
at androidx.test.core.app.InstrumentationActivityInvoker$BootstrapActivity.onResume(InstrumentationActivityInvoker.java:164)
at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1454)
at androidx.test.runner.MonitoringInstrumentation.callActivityOnResume(MonitoringInstrumentation.java:762)
at android.app.Activity.performResume(Activity.java:8103)
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:4441)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:4483)
at android.app.servertransaction.ResumeActivityItem.execute(ResumeActivityItem.java:52)
at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:176)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2175)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:237)
at android.app.ActivityThread.main(ActivityThread.java:7860)
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:1075)
This happened on all tests that uses ActivityScenario#launch(Activity)
, starting from Performance 20.0.0
. Earlier releases worked fine without any code change.
Steps to reproduce:
On an Android project with Firebase Performance setup:
- Create an empty library module (say.
:module
) - Add a dependency to
firebase-perf
within the module - Create an empty activity
- Add the test shown below within
androidTest
directory ./gradlew module:connectedCheck
...or...
- Download & extract MCVE.zip
- Add your
google_services.json
file within:app
./gradlew module:connectedCheck
Relevant Code:
class Repro {
@Test // This will fail with the above stacktrace
fun activityScenario() {
ActivityScenario.launch(MainActivity::class.java).use {
print(0)
}
}
@Test // This will pass
fun nonActivityScenario() {
print(0)
}
}
radityagumay, elevenfive, Anigif, pavelkorolevxyz and niusoundsradityagumayradityagumay