Reputation: 69
public class ApplicationMy extends Application {
private FirebaseAuth firebaseAuth;
@Override
public void onCreate() {
this.firebaseAuth = FirebaseAuth.getInstance();
}
}
And, I also added option of manifests like below
<application
android:name=".ApplicationMy"
...
>
...
</application>
In this case above, app is not dead and looks working well, but error-window occurs...
Like Above case, If i do the code like below, It works well perfectly not showing error window.
public class ApplicationMy extends Application {
private int test;
@Override
public void onCreate() {
this.test = 123;
}
}
What's the problem?
Upvotes: 0
Views: 1375
Reputation: 939
You need to call Firebase.setAndroidContext(Context context) before any other call. Try the following:
public class ApplicationMy extends Application {
private FirebaseAuth firebaseAuth;
@Override
public void onCreate() {
Firebase.setAndroidContext(this);
this.firebaseAuth = FirebaseAuth.getInstance();
}
}
Upvotes: 0
Reputation: 2872
I assume doing that in application class is not the right way. Doing same in an activity wouldn't be a problem.
public class MainActivity extends AppCompatActivity {
private FirebaseAuth firebaseAuth;
@Override
public void onCreate() {
firebaseAuth = FirebaseAuth.getInstance();
}
}
This is what I would ask you to do.
Upvotes: 1