New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding Fabric Crashlytics conflict with Twitter login #533

Closed
cutiko opened this Issue Jan 20, 2017 · 11 comments

Comments

Projects
3 participants
@cutiko

cutiko commented Jan 20, 2017

Greetings

I recently add Fabric so I can track my crash in prod. The app has the Twitter firebase-ui-auth login, the error is the following:

java.lang.IllegalStateException: Must start Twitter Kit with Fabric.with() first

For what I can see I have to start the Twitter kit first, considering Fabric is started in tthe LoginActivity I have try this:

Fabric.with(this, new Crashlytics(), new TwitterCore(new TwitterAuthConfig(getString(R.string.twitter_consumer_key), getString(R.string.twitter_consumer_key))));

But my attempt was in vain.

Some help please :(

[UPDATE: the issue has being solved, please read the thread and see the gist in a further comment]

@samtstern

This comment has been minimized.

Show comment
Hide comment
@samtstern

samtstern Jan 20, 2017

Member

Hmm I don't have any experience using FirebaseUI and Fabric in the same app but given recent news we should definitely sort this out!

I will try to look into it, can you provide some more code/logs and explain exactly where the crash is occurring?

Member

samtstern commented Jan 20, 2017

Hmm I don't have any experience using FirebaseUI and Fabric in the same app but given recent news we should definitely sort this out!

I will try to look into it, can you provide some more code/logs and explain exactly where the crash is occurring?

@cutiko

This comment has been minimized.

Show comment
Hide comment
@cutiko

cutiko Jan 20, 2017

Yes! I have being reading about it, I'm starting to imagine a future where we can login in to Firebase and get everything easily :) With the new integration to Android Studio, and off course Firebase-ui moving from beta to stable, that seems the proper way to provide us android developer with great tools :) I have try with several trackers Fabric is my favorite and was the first service to make me feel that there is someone actually trying to make Android Dev less painfull

  1. When Fabric is added then this issue will happen #450 and it can be fix by doing exactly what is said on that thread

  2. Please consider, that the solution I provided initially is applied in the onCreate method from the launcher Activity, which is also the login Activity. Fabric is initialized in the launcher Activity always (or in the Application Activity).

  3. I'm doing what is indicated in the doc, to start ui login activity

startActivityForResult(
    AuthUI.getInstance()
        .createSignInIntentBuilder()
        .setProviders(Arrays.asList(new AuthUI.IdpConfig.Builder(AuthUI.EMAIL_PROVIDER).build(),
                                    new AuthUI.IdpConfig.Builder(AuthUI.GOOGLE_PROVIDER).build(),
                                    new AuthUI.IdpConfig.Builder(AuthUI.FACEBOOK_PROVIDER).build(),
                                    new AuthUI.IdpConfig.Builder(AuthUI.TWITTER_PROVIDER).build()))
        .build(),
    RC_SIGN_IN);
  1. This is the complete stack trace:
01-20 19:34:24.263 29539-29539/company.coolapp E/AndroidRuntime: FATAL EXCEPTION: main
                                                                              Process: company.coolapp, PID: 29539
                                                                              java.lang.RuntimeException: Unable to start activity ComponentInfo{company.coolapp/com.firebase.ui.auth.ui.idp.AuthMethodPickerActivity}: java.lang.IllegalStateException: Must start Twitter Kit with Fabric.with() first
                                                                                  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)
                                                                                  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
                                                                                  at android.app.ActivityThread.-wrap11(ActivityThread.java)
                                                                                  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
                                                                                  at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                                  at android.os.Looper.loop(Looper.java:148)
                                                                                  at android.app.ActivityThread.main(ActivityThread.java:5417)
                                                                                  at java.lang.reflect.Method.invoke(Native Method)
                                                                                  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
                                                                                  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
                                                                               Caused by: java.lang.IllegalStateException: Must start Twitter Kit with Fabric.with() first
                                                                                  at com.twitter.sdk.android.core.TwitterCore.checkInitialized(TwitterCore.java:160)
                                                                                  at com.twitter.sdk.android.core.TwitterCore.getInstance(TwitterCore.java:76)
                                                                                  at com.twitter.sdk.android.core.identity.TwitterAuthClient.<init>(TwitterAuthClient.java:71)
                                                                                  at com.firebase.ui.auth.provider.TwitterProvider.<init>(TwitterProvider.java:34)
                                                                                  at com.firebase.ui.auth.ui.idp.AuthMethodPickerActivity.populateIdpList(AuthMethodPickerActivity.java:101)
                                                                                  at com.firebase.ui.auth.ui.idp.AuthMethodPickerActivity.onCreate(AuthMethodPickerActivity.java:79)
                                                                                  at android.app.Activity.performCreate(Activity.java:6237)
                                                                                  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
                                                                                  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
                                                                                  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) 
                                                                                  at android.app.ActivityThread.-wrap11(ActivityThread.java) 
                                                                                  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) 
                                                                                  at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                                                  at android.os.Looper.loop(Looper.java:148) 
                                                                                  at android.app.ActivityThread.main(ActivityThread.java:5417) 
                                                                                  at java.lang.reflect.Method.invoke(Native Method) 
                                                                                  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
                                                                                  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 

5.- If new AuthUI.IdpConfig.Builder(AuthUI.TWITTER_PROVIDER).build()) is removed then the problem is solved, but no Twitter login :(

6.- Since I mentioned it above, Fabric can be started in the Application class, I create a class that extend Application, override the onCreate method, add Fabric there Fabric.with(this, new Crashlytics());, register it in the manifest. But this other attempt also didn't worked :(

In case there is anything else I can do, let me know :)

cutiko commented Jan 20, 2017

Yes! I have being reading about it, I'm starting to imagine a future where we can login in to Firebase and get everything easily :) With the new integration to Android Studio, and off course Firebase-ui moving from beta to stable, that seems the proper way to provide us android developer with great tools :) I have try with several trackers Fabric is my favorite and was the first service to make me feel that there is someone actually trying to make Android Dev less painfull

  1. When Fabric is added then this issue will happen #450 and it can be fix by doing exactly what is said on that thread

  2. Please consider, that the solution I provided initially is applied in the onCreate method from the launcher Activity, which is also the login Activity. Fabric is initialized in the launcher Activity always (or in the Application Activity).

  3. I'm doing what is indicated in the doc, to start ui login activity

startActivityForResult(
    AuthUI.getInstance()
        .createSignInIntentBuilder()
        .setProviders(Arrays.asList(new AuthUI.IdpConfig.Builder(AuthUI.EMAIL_PROVIDER).build(),
                                    new AuthUI.IdpConfig.Builder(AuthUI.GOOGLE_PROVIDER).build(),
                                    new AuthUI.IdpConfig.Builder(AuthUI.FACEBOOK_PROVIDER).build(),
                                    new AuthUI.IdpConfig.Builder(AuthUI.TWITTER_PROVIDER).build()))
        .build(),
    RC_SIGN_IN);
  1. This is the complete stack trace:
01-20 19:34:24.263 29539-29539/company.coolapp E/AndroidRuntime: FATAL EXCEPTION: main
                                                                              Process: company.coolapp, PID: 29539
                                                                              java.lang.RuntimeException: Unable to start activity ComponentInfo{company.coolapp/com.firebase.ui.auth.ui.idp.AuthMethodPickerActivity}: java.lang.IllegalStateException: Must start Twitter Kit with Fabric.with() first
                                                                                  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)
                                                                                  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
                                                                                  at android.app.ActivityThread.-wrap11(ActivityThread.java)
                                                                                  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
                                                                                  at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                                  at android.os.Looper.loop(Looper.java:148)
                                                                                  at android.app.ActivityThread.main(ActivityThread.java:5417)
                                                                                  at java.lang.reflect.Method.invoke(Native Method)
                                                                                  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
                                                                                  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
                                                                               Caused by: java.lang.IllegalStateException: Must start Twitter Kit with Fabric.with() first
                                                                                  at com.twitter.sdk.android.core.TwitterCore.checkInitialized(TwitterCore.java:160)
                                                                                  at com.twitter.sdk.android.core.TwitterCore.getInstance(TwitterCore.java:76)
                                                                                  at com.twitter.sdk.android.core.identity.TwitterAuthClient.<init>(TwitterAuthClient.java:71)
                                                                                  at com.firebase.ui.auth.provider.TwitterProvider.<init>(TwitterProvider.java:34)
                                                                                  at com.firebase.ui.auth.ui.idp.AuthMethodPickerActivity.populateIdpList(AuthMethodPickerActivity.java:101)
                                                                                  at com.firebase.ui.auth.ui.idp.AuthMethodPickerActivity.onCreate(AuthMethodPickerActivity.java:79)
                                                                                  at android.app.Activity.performCreate(Activity.java:6237)
                                                                                  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
                                                                                  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
                                                                                  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) 
                                                                                  at android.app.ActivityThread.-wrap11(ActivityThread.java) 
                                                                                  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) 
                                                                                  at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                                                  at android.os.Looper.loop(Looper.java:148) 
                                                                                  at android.app.ActivityThread.main(ActivityThread.java:5417) 
                                                                                  at java.lang.reflect.Method.invoke(Native Method) 
                                                                                  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
                                                                                  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 

5.- If new AuthUI.IdpConfig.Builder(AuthUI.TWITTER_PROVIDER).build()) is removed then the problem is solved, but no Twitter login :(

6.- Since I mentioned it above, Fabric can be started in the Application class, I create a class that extend Application, override the onCreate method, add Fabric there Fabric.with(this, new Crashlytics());, register it in the manifest. But this other attempt also didn't worked :(

In case there is anything else I can do, let me know :)

@samtstern

This comment has been minimized.

Show comment
Hide comment
@samtstern

samtstern Jan 20, 2017

Member

Can you try adding the following code in your Application class (similar to what you tried before):

        TwitterAuthConfig authConfig = new TwitterAuthConfig(
                appContext.getString(R.string.twitter_consumer_key),
                appContext.getString(R.string.twitter_consumer_secret));
        Fabric.with(appContext.getApplicationContext(), new Twitter(authConfig), new Crashlytics());
Member

samtstern commented Jan 20, 2017

Can you try adding the following code in your Application class (similar to what you tried before):

        TwitterAuthConfig authConfig = new TwitterAuthConfig(
                appContext.getString(R.string.twitter_consumer_key),
                appContext.getString(R.string.twitter_consumer_secret));
        Fabric.with(appContext.getApplicationContext(), new Twitter(authConfig), new Crashlytics());
@cutiko

This comment has been minimized.

Show comment
Hide comment
@cutiko

cutiko Jan 20, 2017

Hey! This is a very good step forward, there is a problem, but maybe is not related to this.

  1. I did what you ask me:
TwitterAuthConfig authConfig = new TwitterAuthConfig(getString(R.string.twitter_consumer_key), getString(R.string.twitter_consumer_secret));
        Fabric.with(this, new Twitter(authConfig), new Crashlytics());

It does work, Twitter login is displayed and login is successful. The only difference I can see, with what I originally did is the arguments are in other order, can you please provide with an explanation to know what happened?

2.- After Twitter login was completed, I got an error, so I check if it was due something else. The same email was authentified with google previously. Delete the account and try again, then the login worked. This is the error:

E/AndroidRuntime: FATAL EXCEPTION: main
                                                                              Process: tremolen.prevencionsuicidios, PID: 12212
                                                                              java.lang.IllegalArgumentException: Given String is empty or null
                                                                                  at com.google.android.gms.common.internal.zzac.zzdv(Unknown Source)
                                                                                  at com.google.firebase.auth.FirebaseAuth.fetchProvidersForEmail(Unknown Source)
                                                                                  at com.firebase.ui.auth.ui.idp.CredentialSignInHandler.onComplete(CredentialSignInHandler.java:74)
                                                                                  at com.google.android.gms.tasks.zzc$1.run(Unknown Source)
                                                                                  at android.os.Handler.handleCallback(Handler.java:739)
                                                                                  at android.os.Handler.dispatchMessage(Handler.java:95)
                                                                                  at android.os.Looper.loop(Looper.java:148)
                                                                                  at android.app.ActivityThread.main(ActivityThread.java:5417)
                                                                                  at java.lang.reflect.Method.invoke(Native Method)
                                                                                  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
                                                                                  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

Thanks for the help, Im gonna keep an eye on this to let you know anything else. Please don't forget to explain me why your solution is different from mine, thanks.

cutiko commented Jan 20, 2017

Hey! This is a very good step forward, there is a problem, but maybe is not related to this.

  1. I did what you ask me:
TwitterAuthConfig authConfig = new TwitterAuthConfig(getString(R.string.twitter_consumer_key), getString(R.string.twitter_consumer_secret));
        Fabric.with(this, new Twitter(authConfig), new Crashlytics());

It does work, Twitter login is displayed and login is successful. The only difference I can see, with what I originally did is the arguments are in other order, can you please provide with an explanation to know what happened?

2.- After Twitter login was completed, I got an error, so I check if it was due something else. The same email was authentified with google previously. Delete the account and try again, then the login worked. This is the error:

E/AndroidRuntime: FATAL EXCEPTION: main
                                                                              Process: tremolen.prevencionsuicidios, PID: 12212
                                                                              java.lang.IllegalArgumentException: Given String is empty or null
                                                                                  at com.google.android.gms.common.internal.zzac.zzdv(Unknown Source)
                                                                                  at com.google.firebase.auth.FirebaseAuth.fetchProvidersForEmail(Unknown Source)
                                                                                  at com.firebase.ui.auth.ui.idp.CredentialSignInHandler.onComplete(CredentialSignInHandler.java:74)
                                                                                  at com.google.android.gms.tasks.zzc$1.run(Unknown Source)
                                                                                  at android.os.Handler.handleCallback(Handler.java:739)
                                                                                  at android.os.Handler.dispatchMessage(Handler.java:95)
                                                                                  at android.os.Looper.loop(Looper.java:148)
                                                                                  at android.app.ActivityThread.main(ActivityThread.java:5417)
                                                                                  at java.lang.reflect.Method.invoke(Native Method)
                                                                                  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
                                                                                  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

Thanks for the help, Im gonna keep an eye on this to let you know anything else. Please don't forget to explain me why your solution is different from mine, thanks.

@samtstern

This comment has been minimized.

Show comment
Hide comment
@samtstern

samtstern Jan 20, 2017

Member

The only difference I can see is I'm using Twitter and you were using TwitterCore.

Also are you using version 1.1.1 of FirebaseUI? The crash you're seeing after login is something I think we fixed in the latest version.

Member

samtstern commented Jan 20, 2017

The only difference I can see is I'm using Twitter and you were using TwitterCore.

Also are you using version 1.1.1 of FirebaseUI? The crash you're seeing after login is something I think we fixed in the latest version.

@samtstern samtstern added this to the 1.2.0 milestone Jan 26, 2017

@samtstern

This comment has been minimized.

Show comment
Hide comment
@samtstern

samtstern Jan 31, 2017

Member

@cutiko any update here?

Member

samtstern commented Jan 31, 2017

@cutiko any update here?

@cutiko

This comment has been minimized.

Show comment
Hide comment
@cutiko

cutiko Jan 31, 2017

Dear @samtstern yes sorry for the delay, I have being very busy and will come with something more solid as soon as I can. In the meanwhile I can confirm both fixes (Fabric.with... and updating version).

cutiko commented Jan 31, 2017

Dear @samtstern yes sorry for the delay, I have being very busy and will come with something more solid as soon as I can. In the meanwhile I can confirm both fixes (Fabric.with... and updating version).

@samtstern

This comment has been minimized.

Show comment
Hide comment
@samtstern

samtstern Jan 31, 2017

Member

@cutiko ok great that's all I needed to know, just wanted to make sure those workarounds did it for you so I can consider the best way to fix this

Member

samtstern commented Jan 31, 2017

@cutiko ok great that's all I needed to know, just wanted to make sure those workarounds did it for you so I can consider the best way to fix this

@samtstern samtstern added this to TODO in Version 1.2.0 Jan 31, 2017

@cutiko

This comment has been minimized.

Show comment
Hide comment
@cutiko

cutiko Feb 3, 2017

Greetings

@samtstern thanks for understanding, I feel committed to this community so I had to do something

In case anyone else get in the same problem, this thread is very good, I have also create a gist covering the issues, in case you need more details Fix Firebase Twitter login and Fabric Crash

cutiko commented Feb 3, 2017

Greetings

@samtstern thanks for understanding, I feel committed to this community so I had to do something

In case anyone else get in the same problem, this thread is very good, I have also create a gist covering the issues, in case you need more details Fix Firebase Twitter login and Fabric Crash

@samtstern samtstern moved this from TODO to Punt in Version 1.2.0 Feb 17, 2017

@samtstern samtstern removed this from the 1.2.0 milestone Feb 21, 2017

@SUPERCILEX

This comment has been minimized.

Show comment
Hide comment
@SUPERCILEX

SUPERCILEX Oct 5, 2017

Collaborator

@samtstern I think this issue is no longer relevant since #905.

Collaborator

SUPERCILEX commented Oct 5, 2017

@samtstern I think this issue is no longer relevant since #905.

@samtstern

This comment has been minimized.

Show comment
Hide comment
@samtstern

samtstern Oct 9, 2017

Member

@SUPERCILEX that's correct, closing.

Member

samtstern commented Oct 9, 2017

@SUPERCILEX that's correct, closing.

@samtstern samtstern closed this Oct 9, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment