Test - FirebaseApp is not initialized in this process

I've had the same problem and fixed it by initializing Firebase in the before step of my unit test:

FirebaseApp.initializeApp(InstrumentationRegistry.getInstrumentation().targetContext)

I also had the same issue a few day ago and i solve it in the same way the error says. You get that error because you're trying to get an instance of Firebase without initialize it. Please add this line of code before you try to get an instance of Firebase like this:

FirebaseApp.initializeApp(this);

Also, as Franks says, please be sure you have the following line of code added in your build.gradle file, as the last line of your entire file.

apply plugin: 'com.google.gms.google-services'

Ok, I've figured it out. It's actually a conceptual problem. The problem is that I'm trying to use the Firebase Android SDK to run a test outside of the Android context. I mean, my test is not an Android application, and I'm trying to use the Android SDK. All FirebaseApp.initializeApp() need a Context as a parameter.

So, what I have to do is to find a way to interact with my FirebaseDatabase. I think I can go with firebase-admin, or maybe use this one: https://github.com/bane73/firebase4j

Thank you for taking the time to help me (:

** Update **

I've opted to go with the Firebase REST API https://firebase.google.com/docs/reference/rest/database/

For future reference, I'm giving public full access, by tweaking the rules, so it is easier to write the tests setup and cleanup.