FirebasePerformance.getInstance() is crashing on instrumented unit tests
See original GitHub issueDescribe 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)
}
}
Issue Analytics
- State:
- Created 2 years ago
- Reactions:4
- Comments:6 (3 by maintainers)
Top Results From Across the Web
FirebaseCrashlytics.getInstance() is Crashing App In Multi ...
When calling FirebaseCrashlytics.getInstance() in Activity with another Process the App just crashes without generating any single Stack Trace ...
Read more >Firebase Android SDK Release Notes - Google
Firebase ML Model Downloader version 24.0.2. Fixed an issue where FirebaseModelDownloader.getInstance would crash when using non-default FirebaseApp instances.
Read more >Does Unit-Tested Code Crash? A Case Study of Eclipse - arXiv
Unit -testing, crash incident reports, code coverage, stack traces, software reliability. ∗Chioteli collected the unit testing results and performed the ...
Read more >Crash with ProGuard and Firebase Crashlytics - Google Groups
The release version of the app crashes immediately when opened ... callApplicationOnCreate(Instrumentation.java:1189) ... getInstance()
Read more >Android Instrumented Test crash on Emulator - CircleCI Discuss
Hi, I am building my application with CircleCI. My Instrument tests were running just fine until I extended those with more complicated tests...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Any update on this? tried with all latest version(s) and still the same issue.
It breaks all Compose Layout tests in Library modules 😿
Hi @MrHadiSatrio, thanks for the details. I was able to repro the issue, I’ll try to get in contact with an engineer and see what we can find.