Java.Lang.IllegalStateException: Default FirebaseApp is not initialized in this process TestChartApp.TestChartApp. Make sure to call FirebaseApp.initializeApp(Context) first.
this is my code i am using
FirebaseApp.InitializeApp(this);
try
{
throw new NotImplementedException();
}
catch (System.Exception ex)
{
FirebaseCrash.Report(ex);
}
I am new to implement firebase crash reporting i am trying to implement crash report but it is throwing an error. please help me how can i solve that.
Review your logcat output for FirebaseInitProvider tags, if you are getting:
[FirebaseInitProvider] FirebaseApp initialization unsuccessful
Then the two major things to check:
Make sure that your google-services.json is assigned a build action of GoogleServicesJson
Check that your application package name matches the one that you assigned in the Google Dev. Console
A successful FirebaseApp registration will result in the following logcat:
FirebaseInitProvider: FirebaseApp initialization successful
After assigned the build action as GoogleServicesJson its working.
Try entering the following in MainActivity.cs after the LoadApplication call.
FirebaseApp app = FirebaseApp.InitializeApp(Android.App.Application.Context);
The resolution for me was toggling the BuildAction for the google-services.json to GoogleServicesJson.
Even though the google-services.json properties showed BuildAction set to GoogleServicesJson, I was still having the error "Default FirebaseApp is not initialized in this process Make sure to call FirebaseApp.initializeApp(Context) first".
I was able to resolve this issue by setting BuildAction to "None" then setting it back to "GoogleServicesJson". When I got latest version from source control the BuildAction must not have carried over to my local copy (although it showed as such).
Related
I got this error on sentry panel only on production build variant.
IllegalStateException WorkManager is not initialized properly. You
have explicitly disabled WorkManagerInitializer in your manifest, have
not manually called WorkManager#initialize at this point, and your
Application does not implement Configuration.Provider.
java.util.concurrent.ThreadPoolExecutor in runWorker at line 1167
unlike the error i have no work manager dependency in project
could anyone help ...thanks in advance
I´m really desperate about this problem. I´m trying to solve this issue for such a long time now, but I just can´t get it working.
My goal is to use Firebase withhin my Nativescript-App, which also uses Angular 7, but every time I try to "begin" using firebase, I get the following error:
Default FirebaseApp is not initialized in this process com.nativescript. Make sure to call FirebaseApp.initializeApp(Context) first.
I already tried that. I followed this tutorial:https://github.com/EddyVerbruggen/nativescript-plugin-firebase
My Nativescript App is build in "Typescript", so I choose the Typescript-way.
Since I don´t have the app.js, I started the .init in app.ts like so:
import * as application from "tns-core-modules/application";
import * as FirebaseApp from "nativescript-plugin-firebase/app"
import { environment } from './environments/environment';
FirebaseApp.initializeApp(environment.firebase);
import * as firebase from "nativescript-plugin-firebase";
firebase.init({
// Optionally pass in properties for database, authentication and cloud messaging,
// see their respective docs.
}).then(
() => {
console.log("firebase.init done");
},
error => {
console.log(`firebase.init error: ${error}`);
}
);
application.run({ moduleName: "app-root" });
When I try FirebaseApp.initializeApp(environment.firebase), it crashes and says in the log:
S: firebase.init error: Firebase already initialized
Successfully synced application com.nativescript. on device 97412f42.
System.err: An uncaught Exception occurred on "main" thread.
System.err: Unable to start activity ComponentInfo{com.nativescript./com.tns.NativeScriptActivity}: com.tns.NativeScriptException: Calling js method onCreate failed
System.err: Error: java.lang.IllegalStateException: Default FirebaseApp is not initialized in this process com.nativescript.. Make sure to call FirebaseApp.initializeApp(Context) first.
System.err:
...
That´s interesting, because above it says "already initialized", but right after that it says "FirebaseApp is not initialized". Okay, so I decide to remove firebase.init({...}) because maybe that´s just too much init, but obviously nope:
System.err: Unable to start activity ComponentInfo{com.nativescript./com.tns.NativeScriptActivity}: com.tns.NativeScriptException: Calling js method onCreate failed
System.err: Error: java.lang.IllegalStateException: Default FirebaseApp is not initialized in this process com.nativescript. Make sure to call FirebaseApp.initializeApp(Context) first.
System.err:
...
Don´t worry, I purposly removed com.native.script.THEID, just in case.
When I decide to replace FirebaseApp.initializeApp(environment.firebase) with the firebase.init-part it also gives the same error.
My environment.ts is in a folder called environment and it´s in the same directory as app.ts (the folder).
This is how environment.ts is looking like:
export const environment = {
production: true,
firebase: {
apiKey: 'THE API KEY',
authDomain: 'THE AUTH DOMAIN',
databaseURL: 'THE DATABASE URL',
projectId: 'THE PROJECT ID',
storageBucket: 'THE STORAGE BUCKET',
messagingSenderId: 'THE SENDER ID'
},
};
I already download the google-services.json from Firebase Console (where you setup your App) and pasted it into app/App_Resources/Android/
Please guys, I really don´t know any further. I even tried the second page of Google Search.
If you need any infos, please let me know.
MY SOLUTION
Unfortunately I had to abandon this project and create a new one with angular-templates.
I must have messed something up while enabling mutliDex since I had struggles enabling it back then.
My theory is that, by messing up the activation of multiDex, I probably create two instances of my app build when I run tns run android.
So, the only solution was to start over again, but at least the Firebase initialization works now just fine!
With the Firebase Crashlytics SDK, the documentation explains how you can
force a crash
However, in the line:
Crashlytics.getInstance().crash();
Crashlytics is unrecognized and cannot be imported.
I tried switching to FirebaseCrashlytics.getInstance() but there is no crash() method.
Note: Crashlytics is indeed set up properly - I am able to cause my own crash by looking up a view that does not exist and it is reported correctly.
We have deprecated the force crash method in the new SDK. One example of a way to force a crash is manually throwing an exception
throw new RuntimeException("This is a crash");
I implemented Firebase into a Unity app I am creating. There are two buttons that will run the two functions to create a new user and login an existing user. So far this functionality works on my PC, however whenever I try to deploy it to my android phone or Mac I end up getting the following error in the console.
DllNotFoundException: FirebaseCppApp-5.1.0
Firebase.AppUtilPINVOKE+SWIGExceptionHelper..cctor ()
Rethrow as TypeInitializationException: An exception was thrown by the type initializer for SWIGExceptionHelper
Firebase.AppUtilPINVOKE..cctor ()
Rethrow as TypeInitializationException: An exception was thrown by the type initializer for Firebase.AppUtilPINVOKE
Firebase.AppUtil.SetLogFunction (Firebase.LogMessageDelegate arg0)
It appears there is a missing .dll file, however I cannot for the life of me find out how to include it within the project file. I also have double checked the package name and it is the exact same name as the one made for my Firebase project, the google-services JSON in the root of the project, and the Api compatibility level is set to .NET 2.0. On top of that I also uninstalled and reinstalled the app a few times. I also tried using the Play Services Resolver which didn't help much at all either.
Similar error here, only with Firebase Cloud Messaging. After tinkering around in a fashion similar to yours I concluded that it was caused by corruption during import of Firebase Package.
What worked for me:
Deleted each and every folder created while importing Firebase Package.
Reimported Firebase Package
I'm trying to run a test with Robolectric and it has an integration with Firebase. I have a project MyProject - Test that I'll be using to run the tests in a real instance of the database.
The problem is that, when running cleanup before test, I have the error:
java.lang.IllegalStateException: Default FirebaseApp is not initialized in this process null. Make sure to call FirebaseApp.initializeApp(Context) first.
at com.google.firebase.FirebaseApp.getInstance(Unknown Source)
at com.google.firebase.database.FirebaseDatabase.getInstance(Unknown Source)
at com.cgbros.silkhub.activity.listener.LoginActivityUnitTest.cleanUp(LoginActivityUnitTest.kt:26) <28 internal calls>
The test file:
https://gist.github.com/augustoerico/e88d3e5b59ae5d023d83c114b8ffa708
(I tried to copy-paste the source here. Failed miserably...)
Any insights on how I can make this work?
Thank you!
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.
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'
I used the most simple and straightforward approach.
Since you init your Firebase App in your Application, just create a variable there. For example,
//Your Application.class
open var isTestMode = false
onCreate(){
if(!isTestMode){
//Init your Firebase app
}
}
And then in Robolectric Application just extend your application and override the variable. In this case don't forget to provide configuration
#Config(application = TestApplication::class)
I also faced the above issue. Do all plugin download and checks by nuget. But in the end, I found the crashing was due to , Application Package Name not matching the one Assigned in Google Dev.
Application package name must matche the one that assigned in the Google Dev. Console
after add this line and then you get error
FirebaseApp.initializeApp(this);
then you have to do that also
add this line to Gradle (App)
apply plugin: 'com.google.gms.google-services'
add this line to Gradle (Project)
classpath 'com.google.gms:google-services:3.2.1'
also check if no dependncy is missing and make sure you add google-services.json